Search
 
SCRIPT & CODE EXAMPLE
 

CSHARP

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);
}
Comment

PREVIOUS NEXT
Code Example
Csharp :: monogame button 
Csharp :: how to make randomizer c# 
Csharp :: Unity Object rotation along any axis 
Csharp :: c# get every point in a line in matrix 
Csharp :: top down view player movement 
Csharp :: unity basic public options 
Csharp :: declarar lista c# 
Csharp :: remove string inside curly braces C# 
Csharp :: c sharp system pause equivelent 
Csharp :: wpf binding object get value 
Csharp :: c# split quotation 
Csharp :: how to round to nearest number in array c# 
Csharp :: sort array dotnet 
Csharp :: Create Text File and Write 
Csharp :: declare multiple variables in for loop C# 
Csharp :: how to edit .csproj file 
Csharp :: 405 - HTTP verb used to access this page is not allowed 
Csharp :: c# copy bidimensional array 
Csharp :: c# response.contenttype set filename 
Csharp :: c# read excel file columns using epplus 
Csharp :: C# Async Function simple 
Csharp :: summernote dropdown plugin 
Csharp :: Get replace normal text from word document in C# 
Csharp :: docker-compose cassandra db 
Csharp :: crud operation in asp.net 
Csharp :: c# reflection create generic type 
Csharp :: or operator in c# 
Csharp :: Implementing video array in unity 
Csharp :: AuthenticationTicket authenticationProperties C# .net 
Csharp :: Archivarskodex freischalten 
ADD CONTENT
Topic
Content
Source link
Name
3+1 =