生成唯一吗C#:System.Guid.NewGuid().ToString(format);

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

 

format

说明符             返回值的格式  
 
N                  32   位:  

xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx  
 
D                  由连字符分隔的   32   位数字:  

xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx  
 
B                  括在大括号中、由连字符分隔的   32   位数字:  

{xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx}  
 
P                  括在圆括号中、由连字符分隔的   32   位数字:  

(xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx)
 
 

 

//实例

using System;

class Sample
{
    public static void Main()
    {
    Guid g;
// Create and display the value of two GUIDs.
    g = Guid.NewGuid();
    Console.WriteLine(g);
    Console.WriteLine(Guid.NewGuid());
    }
}

/*
This code example produces the following results:

0f8fad5b-d9cb-469f-a165-70867728950e
7c9e6679-7425-40de-944b-e07fc1f90ae7

*/



评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值