// Collection of code snippets by Arne Vajhøj // (likely posted to comp.os.vms/INFO-VAX, INFO-TPU, MACRO32, eksperten.dk, newz.dk, LinkedIn or other place sometime between 1990 and now) using System; using System.Globalization; namespace E { public class Program { public static float Test(string s) { float number; bool result = float.TryParse(s, NumberStyles.Any, CultureInfo.InvariantCulture, out number); if (result) { return (number/100); } else { return 0; } } public static void Main(string[] args) { Console.WriteLine(Test("274")); Console.WriteLine(Test("2.1")); Console.WriteLine(Test("0.6")); Console.WriteLine(Test("14.1")); } } }