using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Text.RegularExpressions; namespace Casic.Birmm.RbFreqStandMeasure.tools { public class UnitConvertHelper { public static double convertHZ(string currentFreq) { string unit= Regex.Replace(currentFreq, @"\d", ""); double value= Convert.ToDouble(Regex.Replace(currentFreq, @"[^\d.\d]", "")); switch (unit) { case "μHz": return value/1000/1000; case "mHz": return value/1000; case "Hz": return value; case "kHz": return value*1000; case "MHz": return value*1000*1000; default: return 0; } } public static double convertS(string currentPeriod) { string unit = Regex.Replace(currentPeriod,@"\d",""); double value = Convert.ToDouble(Regex.Replace(currentPeriod, @"[^\d.\d]", "")); switch (unit) { case "ns": return value/1000/1000/1000; case "μs": return value/1000/1000; case "ms": return value/1000; case "s": return value; default: return 0; } } /*int convertV(string currentVOLTage) { } */ /** * * 50kHz "+5.00000082583410E+004" "+1.99999966521428E-005" * 20 "+1.99999966774069E-008" * * */ } }