Click here to Skip to main content
15,907,329 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hello!!! Can anyone help me how to cut string in c#? This is the instance in "mymail@gmail.com" i want to cut gmail.com after the "@".

Tnx for your answers...
Posted

try this:-

string[] strEmail= string.Split("mymail@gmail.com","@");


where strEmail is the string Array and

strEmail[1] will be equal to "gmail.com".
 
Share this answer
 
v2
Comments
jake kaif 21-Feb-12 7:08am    
tnx a lot :-bd
Varun Sareen 21-Feb-12 7:16am    
your welcome dear
Either:
C#
string sample = "mymail@gmail.com";
string[] parts = sample.Split('@');

Or:
C#
string sample = "mymail@gmail.com";
string localAddress = sample.SubString(0, sample.IndexOf('@'));

The first will break it into two parts:
C#
"mymail"
"gmail.com"
The second will remove the "@" and everything to it's right.
 
Share this answer
 
Comments
jake kaif 21-Feb-12 7:03am    
tnx OriginalGriff... :-bd

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900