get number from string c# code example
Example 1: c# get number from string
// You can use .NET methods to find specific numbers or characters from strings
// Below is the IndexOf method:
string example = "abc 123";
int numbers = example.IndexOf("123");
int totalNumbers = example[numbers];
Example 2: get first number in string C#
var input = "12985bwevgjb9812";
string firstDigit = new String(input.TakeWhile(Char.IsDigit).ToArray());