Thursday, December 9, 2010

Substring

string  s = "bloger";

//and then i want to remove the last chars "er"


string  g = s.Substring(0, s.Length - 2);


it will give     only  'blog'

to cut  first letter ,we start the sub string  from 1
string  g = s.Substring(1, s.Length - 2);

it will give  'log'  by removing first 2 letters and last 2 letters(chars)

No comments:

Post a Comment