converet string to guid c# code example
Example 1: string to guid c#
Guid newGuid = Guid.Parse(stringGuid);
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");
}