using System; public class Test { public static void Main() { string s = " 1.2 3.4 5.6 8.9 "; int startIdx, endIdx = 0; while(true) { startIdx = endIdx; // no find_first_not_of in C# while (startIdx < s.Length && s[startIdx] == ' ') startIdx++; if (startIdx == s.Length) break; endIdx = s.IndexOf(' ', startIdx); if (endIdx == -1) endIdx = s.Length; // how to extract a double here? Console.WriteLine("|" + s.Substring(startIdx, endIdx - startIdx) + "|"); } } }