Saturday, March 31, 2012

Trim the first character

How do i trim the first character.
I have string $22.22 and i want to be left with 22.22
I cant use subString(int,int) because i dont know the length of the stringYou can determine the length using the .Length property. So you can trim in C# like this:
string s = "$22.22";
s = s.Substring(1, s.Length - 1);
's' will now be "22.22"
There is also an overloaded substring method that only requires the starting character position:

strimmed=s.substring(1)

0 comments:

Post a Comment