c sharp guid parse code example
Example 1: how to convert string to guid c#
Guid newGuid = Guid.Parse("9940548e-dadc-405f-83f9-57431685cf5d")
Example 2: c# convert string to system.guid
Guid originalGuid = Guid.NewGuid();
string[] stringGuids = { originalGuid.ToString("B"),
originalGuid.ToString("D"),
originalGuid.ToString("X") };
foreach (var stringGuid in stringGuids)
{
if (Guid.TryParse(stringGuid, out var newGuid))
Console.WriteLine($"Converted {stringGuid} to a Guid");
else
Console.WriteLine($"Unable to convert {stringGuid} to a Guid");
}