public void NumericUtility_TryParseUInt16_1() { ushort value; Assert.IsTrue(NumericUtility.TryParseUInt16("123", out value)); Assert.AreEqual(123, value); Assert.IsFalse(NumericUtility.TryParseUInt16("hello", out value)); Assert.IsFalse(NumericUtility.TryParseUInt16(string.Empty, out value)); Assert.IsFalse(NumericUtility.TryParseUInt16(null, out value)); }
public static ushort GetUInt16 ( [NotNull] string key, ushort defaultValue = 0 ) { string setting = CM.AppSettings[key]; if (!NumericUtility.TryParseUInt16(setting, out ushort result)) { result = defaultValue; } return(result); }
public static ushort GetUInt16 ( [NotNull] string key, ushort defaultValue ) { #if DROID || ANDROID || UAP return(defaultValue); #else ushort result; string s = CM.AppSettings[key]; if (!NumericUtility.TryParseUInt16(s, out result)) { result = defaultValue; } return(result); #endif }