How to Generate Unique ID in C# ?

Do you want to generate a unique id in C# ? . You can use Guid to generate unique data or ID. Below is a sample code snippet that demonstrates how to generate unique ID in C# .

How to Generate Unique ID in C# ?

using System;
using System.Collections.Generic;
using System.Globalization;
using System.Linq;
using System.Text;
using System.Threading;
using System.Threading.Tasks;

namespace AbundantcodeConsoleApp
{
    internal class Program
    {
        private static void Main(string[] args)
        {
            // How to Generate Unique ID in C# ?
           Guid UniqueID = Guid.NewGuid();
           Console.WriteLine("Unique ID (GUID) : " + UniqueID);
           Console.ReadLine();
        }     
    }
    
}
1