Search
 
SCRIPT & CODE EXAMPLE
 

CSHARP

random character c#

//Random Uppercase letter:
Random rnd = new Random();            
int ascii_index = rnd.Next(65, 91); //ASCII character codes 65-90
char myRandomUpperCase = Convert.ToChar(ascii_index); //produces any char A-Z

//random lowercase letter:
Random rnd2 = new Random();            
int ascii_index2 = rnd2.Next(97, 123); //ASCII character codes 97-123
char myRandomLowerCase = Convert.ToChar(ascii_index2); //produces any char a-z

//Random letter irrespective of case: (search up "random number from 2 different ranges" for explanation)
int i = rnd.Next(1, 3) == 1 ? rnd.Next(65, 91) : rnd.Next(97, 123);
char anyLetter = Convert.ToChar(i);
Comment

PREVIOUS NEXT
Code Example
Csharp :: countdown timer c# unity 
Csharp :: if exist TempData[] c# 
Csharp :: c# random choice 
Csharp :: convert bytes to string and back c# 
Csharp :: load prefab in script unity 
Csharp :: unity temperature to colour 
Csharp :: bower azure repository tag 
Csharp :: how to stop player rotating when hit by object 
Csharp :: using tmp unity 
Csharp :: action being performed on this control is being called from the wrong thread c# 
Csharp :: check if network is available c# 
Csharp :: generate a random number in c# 
Csharp :: c# unity 2d play video 
Csharp :: c# file exist 
Csharp :: no move arrows unity 
Csharp :: detect trigger in unity 
Csharp :: checkbox value unchecked after return view model 
Csharp :: unity how to change the text on a button 
Csharp :: dictionary c# 
Csharp :: unity vscode launch.json 
Csharp :: loop over all values in enum 
Csharp :: conditional blazor styles 
Csharp :: unity print name of button when click on it 
Csharp :: blazor option selected 
Csharp :: bootstrap distane between col 
Csharp :: c# run file 
Csharp :: unity how to stop the game 
Csharp :: c# relative path to project folder 
Csharp :: loop over enum values 
Csharp :: .net core check if user is logged in 
ADD CONTENT
Topic
Content
Source link
Name
6+1 =