• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1355
  • Last Modified:

Remove first character in a do while statement

I have a Do while statement that I can't get to work. What I would like to do is trim the front of a text box.  For example if a user enters "0001" I would like to trim it to "1".  I think I'm using the Remove function wrong because it just goes on continuous loop right now.  Thanks
string Search = Convert.ToString(SearchTextBox.Text);
            do
            {
                Search.Remove(0);
            }
            while (Search.StartsWith("0"));

Open in new window

0
deloused
Asked:
deloused
1 Solution
 
gregoryyoungCommented:
string search="000000120";
search = search.TrimStart('0');

Cheers,

Greg
0
 
Juan_BarreraCommented:
Try this:

string s = SearchTextBox.Text;
        string Search = Convert.ToString(s);
        do
        {
            s = s.Remove(0, 1);
        }
        while (s.StartsWith("0"));

Open in new window

0
 
delousedAuthor Commented:
Thanks, worked perfect!
0

Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now