java system.guid g=new guid(_Guid.NewGuid 方法 (System) | Microsoft Docs

初始化 Guid 结构的新实例。Initializes a new instance of the Guid structure.

public:

static Guid NewGuid();

public static Guid NewGuid ();

static member NewGuid : unit -> Guid

Public Shared Function NewGuid () As Guid

返回

一个新的 GUID 对象。A new GUID object.

示例

下面的代码示例创建并显示两个对象的值 Guid 。The following code example creates and displays the values of two Guid objects.

// Create and display the value of two GUIDs.

Guid g = Guid.NewGuid();

Console.WriteLine(g);

Console.WriteLine(Guid.NewGuid());

// This code example produces a result similar to the following:

// 0f8fad5b-d9cb-469f-a165-70867728950e

// 7c9e6679-7425-40de-944b-e07fc1f90ae7' This code example demonstrates the Guid.NewGuid() method.

Class Sample

Public Shared Sub Main()

Dim g As Guid

' Create and display the value of two GUIDs.

g = Guid.NewGuid()

Console.WriteLine(g)

Console.WriteLine(Guid.NewGuid())

End Sub

End Class

'

'This code example produces the following results:

'

'0f8fad5b-d9cb-469f-a165-70867728950e

'7c9e6679-7425-40de-944b-e07fc1f90ae7

'

注解

这是一种便捷的 static 方法,可以调用它来获取新的 Guid 。This is a convenient static method that you can call to get a new Guid. 方法包装对 Windows CoCreateGuid 函数的调用。The method wraps a call to the Windows CoCreateGuid function. The returned Guid is guaranteed to not equal Guid.Empty.

适用于

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值