top of page

Guids

What is a Guid? GUID is an acronym that stands for Globally Unique Identifier, they are also referred to as UUIDs or Universaly Unique Identifiers - there is no real difference between the two. It is a unique ID used that is easy to translate between multiple Windows platforms and languages, such as C#, JSON, Javascript, etc.


Normally, you’ll find a Guid already created in SQL or something similar. If you need to create a Guid in your C# code, here is a fantastic little site that will generate a random Guid with a few specifications you control.



Options you can choose:

  • choose to create up to 2,000 Guids

  • specify upper or lowercase

  • add surrounding curly braces

  • add hyphens

  • URL encoded

There are a few more options but I don’t use them and don’t want offer an incorrect explanation. For more detail on extra options, please review the documentation on the guidgenerator site.


This nifty little tool helps if you need to create some generic guids to test your code before connecting to actual data.


If you just need to create a random guid to insert into SQL through your code at runtime, you should use something like this:

 
cmdInsert.Parameters.AddWithValue ("@guid", Guid.NewGuid ());
 

14 views0 comments

Kommentare


bottom of page