Remove particular Starting or Ending character in the string

Sathya4260
Posted by Sathya4260 under C# category on | Points: 40 | Views : 2293
Hi,

Sometimes if the user enters the value as 03, we have to save or get the data as 3, Here is the simple code to achieve this

string testing="03";
Int trim=Conver.ToInt32(testing.TrimStart('0'));


Ouput: 3

The same way, If we need to remove the character at the end of the string,Use

 Int trim=Conver.ToInt32(testing.TrimEnd('0'));

Comments or Responses

Login to post response