Glenn Patton

Glenn Patton

  • NA
  • 308
  • 82.8k

Search a for values in a string

Jul 17 2012 8:54 AM
Hi All,

I'm looking for a good method of searching a string for a value, if the string was all numbers I would use a Convert.ToInt16() (or 32 depending on value) but this time the string in question is  "2.08.08" if this is Converted with a ToInt() method it will error as the decimal is used twice.  
The reason I can't use a substring() method to chop off the first is it is a version number so all the digits are important.  I could use a foreach loop to remove the stops and then convert the string (2.08.08 would become 20808) and use it like that:

            foreach (string subString in USB_Version.Split(Stop))
            {
                output += subString + ";";
                count++;
                if (count == 3)
                {
                    Version_Number = subString;
                    break;
                } 
Would this be good method or is there (as usual) a method I am not aware of??
Glenn

Answers (6)