Convert a String to a GUID in C#
This is a simple one that didn’t take all that long to find a solution for but I thought it was worth putting up here anyhow seeing it’s not all that obvious.
To convert most other data types (Strings, Ints, Chars etc) you use the Convert. system function eg.
char myChar = Convert.ToChar(myString); char myInt = Convert.ToInt(myString);
But GUIDs are treated a little differently, you actually create a new instance seeded with the string value eg.
Guid myGuid = new Guid(myString);