Tuesday, September 6, 2011

two string manipulations

Split a string:

string emailAddress = "tomjaeschke@tomjaeschke.com";

string[] splitUponAtSymbol = emailAddress.Split("@".ToCharArray());

string domainNameHalfOfEmailAddress = splitUponAtSymbol[1];

 
 

Remove the first two characters from a string:

string listOfFoo = "";

foreach (Bar bar in Whatever)

{

   listOfFoo = listOfFoo + ", " + bar.Foo;

}

listOfFoo = listOfFoo.Substring(2, listOfFoo.Length - 2);

No comments:

Post a Comment