feat: Adding TryFromIpIdString method

This commit is contained in:
Chris Cameron
2018-10-29 14:13:46 -04:00
parent 24e665de84
commit db14eb1dde
2 changed files with 41 additions and 9 deletions

View File

@@ -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>