mirror of
https://github.com/ICDSystems/ICD.Common.Utils.git
synced 2026-02-14 20:25:01 +00:00
feat: Adding TryFromIpIdString method
This commit is contained in:
@@ -564,6 +564,30 @@ namespace ICD.Common.Utils
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Formats "0xFF" to an IPID.
|
||||
/// </summary>
|
||||
/// <param name="value"></param>
|
||||
/// <param name="result"></param>
|
||||
/// <returns></returns>
|
||||
public static bool TryFromIpIdString(string value, out byte result)
|
||||
{
|
||||
if (value == null)
|
||||
throw new ArgumentNullException("value");
|
||||
|
||||
result = 0;
|
||||
|
||||
try
|
||||
{
|
||||
result = (byte)Convert.ToInt64(value, 16);
|
||||
return true;
|
||||
}
|
||||
catch (ArgumentOutOfRangeException)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Removes all whitespace from the string.
|
||||
/// </summary>
|
||||
|
||||
Reference in New Issue
Block a user