john G john G - 1 year ago 157
ASP.NET (C#) Question

How to get a substring after certain character

i need to extract the company name from an email inside my mvc web application:-
for exmaple if i have an

email address =

to get
with first letter capital?

Answer Source
string address = "";
string name = address.Split('@')[1].Split('.')[0];
name = name.Substring(0,1).ToUpper() + name.Substring(1); // Mycompanyname

Another option to get name is regular expression:

var name = Regex.Match(address, @"@([\w-]+).").Groups[1].Value
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download