diff options
| author | ivarlovlie <git@ivarlovlie.no> | 2021-04-28 21:29:43 +0200 |
|---|---|---|
| committer | ivarlovlie <git@ivarlovlie.no> | 2021-04-28 21:29:43 +0200 |
| commit | 477b59043f1ce9aed58ca9afc517e34db04e47b3 (patch) | |
| tree | 0a211345032f5fc158d354055d277eb7f77a0e25 | |
| parent | 16515f5431ef650c6be811d7377803378a50f11c (diff) | |
| download | dotnet-helpers-477b59043f1ce9aed58ca9afc517e34db04e47b3.tar.xz dotnet-helpers-477b59043f1ce9aed58ca9afc517e34db04e47b3.zip | |
Make ToGuid safe (not able to throw)
| -rw-r--r-- | src/IOL.Helpers/StringHelpers.cs | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/src/IOL.Helpers/StringHelpers.cs b/src/IOL.Helpers/StringHelpers.cs index 0c25184..6589df6 100644 --- a/src/IOL.Helpers/StringHelpers.cs +++ b/src/IOL.Helpers/StringHelpers.cs @@ -40,7 +40,7 @@ namespace IOL.Helpers } public static Guid ToGuid(this string value) { - return Guid.Parse(value); + return !Guid.TryParse(value, out var res) ? default : res; } public static string Base64Encode(this string text) { |
