How to generate and obtain GUID in C#

Function to generate GUID:

Private string getGUID ()

{

System. Guid Guid = new Guid();

guid = Guid。 new guid();

string str = guid。 ToString();

Returns a string;

}

Randomly generate the following string:

e92b 8e 30-a6e 5-4 1 F6-a6b 9- 188230 a23d 2

Format description:

System. Guid.NewGuid()。 ToString (format)

Format specifier

Format of return value

N 32 bits:

xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx

Such as: E928B8E30A6E54186B69188230A23D2.

D 32-digit numbers separated by hyphens:

xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx

For example: E92b2e30-A6E5-41F6-A6B9-188230A23D2.

B 32-bit numbers enclosed in braces and separated by hyphens:

{ xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx }

Such as: {E92B2E30-A6E5-41F6-A6B9-188230A23D2}

P 32-bit numbers in brackets and separated by hyphens:

(xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx)

Such as: (E92B2E30-A6E5-41F6-A6B9-188230A23D2)