GUID (globally unified identifier) refers to the number generated on a machine, which ensures that all machines in the same time and space are unique. Generally, the platform provides APIs for generating guids. The generation algorithm is very interesting. It uses Ethernet Card addresses, nanoseconds, chip ID codes, and many possible numbers. The only drawback of GUID is that the generated result string is large ."
1. a guid is a 128-bit integer (16 bytes). When using a unique identifier, you can use this integer between all computers and networks.
2. The GUID format is "xxxxxxxx-xxxx-xxxxxxxxxxxx", where each x is a hexadecimal number in the range of 0-9 or a-f. For example, 337c7f2b-7a34-4f50-9141-bab9e6478cc8 is a valid GUID value.
3. No duplicate GUID value is generated on any two computers in the world (Koffer Note: it should be on the Earth. GUID is used to assign a unique identifier to a network or system with multiple nodes and computers.
4. On Windows, GUID is widely used: Registry, class and interface identification, database, or even automatically generated machine name and directory name.
GUID generated in SQL SERVER
The SQL Server Data Type uniqueidentifier can store a GUID value. You can useNEWID ()The function generates this value in SQL Server.
Generate GUID in. NET Program
The Guid structure is used to generate: Guid. NewGuid (). ToString (). Note that the method here isNewGuid ()Is different from the function name in the database. I made a mistake here, thinking that NewGuid () is also used in the database ()
C #
- Using System;
- Namespace ConAppLogTest
- {
- Public class Program
- {
- Static void Main (string [] args)
- {
- String guid = System. Guid. NewGuid (). ToString ();
- Console. WriteLine (guid );
- }
- }
- }
Output:
GUID: c4208862-c7fe-4d14-86d4-7bd5c55bd850
Press any key to continue...
Converts a string to a GUID.
C #
- String id = "c4208862-c7fe-4d14-86d4-7bd5c55bd850 ";
- Guid guid = System. Guid. Parse (id );