mirror of
https://github.com/ICDSystems/ICD.Common.Utils.git
synced 2026-02-14 20:25:01 +00:00
add tryparse for short, ushort, long, and ulong
This commit is contained in:
@@ -191,6 +191,54 @@ namespace ICD.Common.Utils
|
||||
return TryConvert(Convert.ToUInt32, value, out result);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Attempts to parse the string as a short integer.
|
||||
/// </summary>
|
||||
/// <param name="value"></param>
|
||||
/// <param name="result"></param>
|
||||
/// <returns></returns>
|
||||
[PublicAPI]
|
||||
public static bool TryParse(string value, out short result)
|
||||
{
|
||||
return TryConvert(Convert.ToInt16, value, out result);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Attempts to parse the string as an unsigned short integer.
|
||||
/// </summary>
|
||||
/// <param name="value"></param>
|
||||
/// <param name="result"></param>
|
||||
/// <returns></returns>
|
||||
[PublicAPI]
|
||||
public static bool TryParse(string value, out ushort result)
|
||||
{
|
||||
return TryConvert(Convert.ToUInt16, value, out result);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Attempts to parse the string as a long integer.
|
||||
/// </summary>
|
||||
/// <param name="value"></param>
|
||||
/// <param name="result"></param>
|
||||
/// <returns></returns>
|
||||
[PublicAPI]
|
||||
public static bool TryParse(string value, out long result)
|
||||
{
|
||||
return TryConvert(Convert.ToInt64, value, out result);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Attempts to parse the string as an unsigned long integer.
|
||||
/// </summary>
|
||||
/// <param name="value"></param>
|
||||
/// <param name="result"></param>
|
||||
/// <returns></returns>
|
||||
[PublicAPI]
|
||||
public static bool TryParse(string value, out ulong result)
|
||||
{
|
||||
return TryConvert(Convert.ToUInt64, value, out result);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Attempts to parse the string as a float.
|
||||
/// </summary>
|
||||
|
||||
Reference in New Issue
Block a user