-6

I want to trim an email to get the username only. In other words for example I have :

admin@example.com

I want to trim this string to get admin only that is trim everything after the @ sign using mvc 5 or C# how could that happen?

mohammad
  • 297
  • 1
  • 5
  • 19
  • 4
    Stack Overflow isn't a place to have your work done for you for free. Provide what you have tried and we can help fix anything that might not be working. – leigero Dec 09 '14 at 11:48
  • 3
    Have a look at `Substring` and `IndexOf` – Magnus Dec 09 '14 at 11:49
  • 2
    "how could that happen?" go to stackoverflow and show some of your work... then you will get some help... or go to google and search and read and try. – Paul Zahra Dec 09 '14 at 11:56

1 Answers1

3
string test = admin@example.com

string[] arr = test.Split('@');

string userNAme = arr[0];

Here next time use google ...

You can see this examples and this documentation.

mybirthname
  • 17,949
  • 3
  • 31
  • 55