Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Create GUID constants? (VB.net)

Public Const ClassId = "92A1377A-7A3C-4FAF-94DA-C229AFFCFB12" Public Const InterfaceId = "2DE393C7-300A-46DB-B33C-583B2765C2F9" Public Const EventsId = "5452FC4D-C0C2-4E2B-87CA-8F43EAA14998"

I found this in a code snippet and need to create my own GUID in vb.net. But I didn't find a way that the program automatically creates constantes like this and shows them in the code. How can I do that? I'm not yet familiar with GUIDs but I suppose there were created automatically.

Thanks for any hints :)

like image 635
Dyrdek Avatar asked Oct 22 '25 16:10

Dyrdek


1 Answers

First point is that you cannot apply const modifier to GUID's as const is applied on primitive datatype. If you want you can use Shared ReadOnly.

Second point is you can refer Guid.NewGuid Method () which is used to create GUID. Something like

Dim str = Guid.NewGuid.ToString()

EDIT:

A good MSDN reference which you have found yourself can be helpful.

like image 195
Rahul Tripathi Avatar answered Oct 25 '25 05:10

Rahul Tripathi