c# use random to generate guid code example Example: generate guid c# Guid g = Guid.NewGuid(); string guid = Guid.NewGuid().ToString();