How to generate a GUID or UUID in C#


In order to generate a GUID in c# you can use this code, depending on your requirements:

//generate a new guid with value in c# code Guid guid = Guid.NewGuid(); ... //generate a new EMPTY guid: 00000000-0000-0000-0000-000000000000 Guid guid = new Guid(); //or Guid guid = Guid.Empty; ... //get the guid value as string Guid guid = Guid.NewGuid(); var svalue = guid.ToString();
You can also generate a GUID (UUID) with multiple options using our tool here: Online GUID (UUID) Generator