private static void Main(string[] args) { TextScanner s = null; double sum = 0; try { s = new TextScanner(new StreamReader("usnumbers.txt")); s.UseCulture(new CultureInfo("en-US")); while (s.HasNext()) { if (s.HasNextDouble()) { sum += s.NextDouble(); } else { s.Next(); } } } finally { if (s != null) { s.Close(); } } Console.WriteLine(sum); }
private static void Main(string[] args) { TextScanner s = null; try { s = new TextScanner(new StreamReader("xanadu.txt")); while (s.HasNext()) { Console.WriteLine(s.Next()); } } finally { if (s != null) { s.Close(); } } }