public UnitValue(string sVal) { if (String.IsNullOrWhiteSpace(sVal)) { throw new ArgumentException(); } ValueQualifier vq = DoubleValue.FindQualifier(ref sVal); foreach (String fs in _falseStarts) { if (sVal.StartsWith(fs)) { sVal = sVal.Substring(fs.Length + 1).Trim(); break; } } sVal = RemoveBrackets(sVal); int i1 = 0; bool dF = false; while (i1 < sVal.Length && !IsDigit(sVal[i1], ref dF)) { i1++; } StringBuilder sb = new StringBuilder(); dF = false; while (i1 < sVal.Length && IsDigit(sVal[i1], ref dF)) { sb.Append(sVal[i1++]); } if (sb.Length == 0) { throw new ArgumentException(String.Format("Unable to parse double from string '{0}'.", sVal)); } Value = double.Parse(sb.ToString()); sVal = sVal.Substring(i1).Trim(); Units = sVal; Qualifier = vq; }
public static QualifiedString Parse(string v) { ValueQualifier vq = DoubleValue.FindQualifier(ref v); return(new QualifiedString(v.Trim(), vq)); }