Here is source code of the C# Program to Implement String Splitter. The C# program is successfully compiled and executed with Microsoft Visual Studio. The program output is also shown below.
* C# Program to Implement String Splitter
static void Main()
string sentence = "School had 40 Rooms, 500 Boys, 500 Girls and 250 Teachers";
string digits = Regex.Split(sentence, @"\D+");
foreach (string value in digits)
if (int.TryParse(value, out number))
Here is the output of the C# Program:
40 500 500 250
Sanfoundry Global Education & Learning Series – 1000 C# Programs.