mirror of
https://github.com/ICDSystems/ICD.Common.Utils.git
synced 2026-02-15 20:54:58 +00:00
feat: Add TryParse overload method to StringUtils, which tries to parse a GUID from a string
This commit is contained in:
@@ -355,6 +355,27 @@ namespace ICD.Common.Utils
|
||||
return TryConvert(Convert.ToBoolean, value, out result);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Attempts to parse the string as a guid.
|
||||
/// </summary>
|
||||
/// <param name="value"></param>
|
||||
/// <param name="result"></param>
|
||||
/// <returns></returns>
|
||||
[PublicAPI]
|
||||
public static bool TryParse([NotNull] string value, out Guid result)
|
||||
{
|
||||
try
|
||||
{
|
||||
result = new Guid(value);
|
||||
return true;
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
result = Guid.Empty;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Attempts to parse the string via the given conversion function.
|
||||
/// </summary>
|
||||
|
||||
Reference in New Issue
Block a user