public void NumericUtility_TryParseInt64_1() { long value; Assert.IsTrue(NumericUtility.TryParseInt64("123", out value)); Assert.AreEqual(123, value); Assert.IsFalse(NumericUtility.TryParseInt64("hello", out value)); Assert.IsFalse(NumericUtility.TryParseInt64(string.Empty, out value)); Assert.IsFalse(NumericUtility.TryParseInt64(null, out value)); }
/// <summary> /// Get 64-bit integer value /// from application configuration. /// </summary> public static long GetInt64 ( [NotNull] string key, long defaultValue = 0L ) { string setting = CM.AppSettings[key]; if (!NumericUtility.TryParseInt64(setting, out long result)) { result = defaultValue; } return(result); }
/// <summary> /// Get 64-bit integer value /// from application configuration. /// </summary> public static long GetInt64 ( [NotNull] string key, long defaultValue ) { #if DROID || ANDROID || UAP return(defaultValue); #else long result; string s = CM.AppSettings[key]; if (!NumericUtility.TryParseInt64(s, out result)) { result = defaultValue; } return(result); #endif }