best way to break the string number

I have made this code which works perfectly well for breaking a string number which comes for example from a database like (“00340”) into int (340). But I am not really sure if its the best way to do so.

void breakToNumber(string number,int length)
  int result=0;
  int timesSpot=length;
  int i;
    result+=(int)char.GetNumericValue(number_)*(int)Mathf.Pow (10,timesSpot);_

print (result);
If you’ll find any better way to break such a string, i’ll be more than happy to replace this method. And if not, I’ll be more than happy to share this method.

If all you need to do is convert a string to a number then you should be able to use:


If you’re using C# take a look at the Convert class.

You can simply use Convert.ToInt32(“00340”). The intern calculating should be faster then pow’ing the single digits manually and its much easier to understand.