Answers for "how to create unique guid in c#"

C#
3

unique id c#

public string generateID()
{
    return Guid.NewGuid().ToString("N");
}
Posted by: Guest on August-10-2021
0

how to generate random unique id in c#

public Random a = new Random(); // replace from new Random(DateTime.Now.Ticks.GetHashCode());
                                // Since similar code is done in default constructor internally
public List<int> randomList = new List<int>();
int MyNumber = 0;
private void NewNumber()
{
  	MyNumber = a.Next(0, 10);
  	while(randomList.Contains(MyNumber))
    	MyNumber = a.Next(0, 10);
}
Posted by: Guest on April-03-2020
0

unique id c#

public string generateID(string sourceUrl)
{
    return string.Format("{0}_{1:N}", sourceUrl, Guid.NewGuid());
}
Posted by: Guest on August-10-2021

C# Answers by Framework

Browse Popular Code Answers by Language