How to work with GUIDs in C# 8

Take advantage of GUIDs to create universally unique identifiers and avoid data collisions in your applications

How to work with GUIDs in C# 8
Thinkstock

When working in applications you might often need to use Globally Unique Identifiers (GUIDs). Unique identifiers like primary keys in a SQL database ensure that important objects like customers and invoices are not duplicated or overwritten. Without unique identifiers, we could not prevent data loss or ensure the data integrity of our applications. 

A Globally Unique Identifier or GUID represents a gigantic identification number — a number so large that it is mathematically guaranteed to be unique not only in a single system like a database, but across multiple systems or distributed applications. This article discusses why we need GUIDs and how we can work with GUIDs in C# 8.0.

To work with the code examples provided in this article, you should have Visual Studio 2019 installed in your system. If you don’t already have a copy, you can download Visual Studio 2019 here

Create a console application project in Visual Studio

First off, let’s create a .NET Core Console Application project in Visual Studio. Assuming Visual Studio 2019 is installed in your system, follow the steps outlined below to create a new .NET Core Console Application project in Visual Studio.

To continue reading this article register now

How to choose a low-code development platform