From 0b05a87653251621d2b728f579162950cac98637 Mon Sep 17 00:00:00 2001 From: Jack Kanarish Date: Fri, 5 Jan 2018 11:06:00 -0500 Subject: [PATCH] add tryparse for short, ushort, long, and ulong --- ICD.Common.Utils/StringUtils.cs | 48 +++++++++++++++++++++++++++++++++ 1 file changed, 48 insertions(+) diff --git a/ICD.Common.Utils/StringUtils.cs b/ICD.Common.Utils/StringUtils.cs index 8d8c0c8..df05254 100644 --- a/ICD.Common.Utils/StringUtils.cs +++ b/ICD.Common.Utils/StringUtils.cs @@ -191,6 +191,54 @@ namespace ICD.Common.Utils return TryConvert(Convert.ToUInt32, value, out result); } + /// + /// Attempts to parse the string as a short integer. + /// + /// + /// + /// + [PublicAPI] + public static bool TryParse(string value, out short result) + { + return TryConvert(Convert.ToInt16, value, out result); + } + + /// + /// Attempts to parse the string as an unsigned short integer. + /// + /// + /// + /// + [PublicAPI] + public static bool TryParse(string value, out ushort result) + { + return TryConvert(Convert.ToUInt16, value, out result); + } + + /// + /// Attempts to parse the string as a long integer. + /// + /// + /// + /// + [PublicAPI] + public static bool TryParse(string value, out long result) + { + return TryConvert(Convert.ToInt64, value, out result); + } + + /// + /// Attempts to parse the string as an unsigned long integer. + /// + /// + /// + /// + [PublicAPI] + public static bool TryParse(string value, out ulong result) + { + return TryConvert(Convert.ToUInt64, value, out result); + } + /// /// Attempts to parse the string as a float. ///