How do I get the left of "@" character from the emailID string "[email protected]" in C#
Thanks
string email = "[email protected]";
int index = email.IndexOf("@");
string user = (index > 0 ? email.Substring(0, index) : "");
var email = "[email protected]";
var name = email.Substring(0, email.IndexOf("@"));
You'll want to do some sanity checks like make sure it's not null and that you actually find the "@" sign.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With