標籤:style http ar os 使用 sp for strong on
一 C# 通用唯一識別碼 (GUID)
Represents a globally unique identifier (GUID).
To browse the .NET Framework source code for this type, see the Reference Source.
Namespace: System
Assembly: mscorlib (in mscorlib.dll)
GUID 是一個 128 位整數(16 位元組),可用於所有需要唯一識別碼的電腦和網路。 此標識符重複的可能性非常小。
二 GUID使用樣本(C#)
private string getGUID(int type)
{
System.Guid guid = new Guid();
guid = Guid.NewGuid();
string stmp= "";
if(type==0)
{
guid.ToString("N");
}
else if(type==1)
{
guid.ToString("D");
}
else if(type==2)
{
guid.ToString("B");
}
else if(type==3)
{
guid.ToString("P");
}
return stmp;
}
格式說明符
傳回值的格式
N 32位:
xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
如:e92b8e30a6e541f6a6b9188230a23dd2
D 由連字號分隔的32位元字:
xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx
如:e92b8e30-a6e5-41f6-a6b9-188230a23dd2
B 括在大括弧中、由連字號分隔的32位元字:
{xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx}
如:{e92b8e30-a6e5-41f6-a6b9-188230a23dd2}
P 括在圓括弧中、由連字號分隔的32位元字:
(xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx)
如:(e92b8e30-a6e5-41f6-a6b9-188230a23dd2)
C# 通用唯一識別碼 (GUID)