generate random string C#

private static Random random = new Random();
public static string RandomString(int length)
{
    const string chars = "ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789";
    return new string(Enumerable.Repeat(chars, length)
      .Select(s => s[random.Next(s.Length)]).ToArray());
}

4
3
Englishfox 85 points

                                    Namespace: System.Web.Security
public string GeneratePassword()
{
	return Membership.GeneratePassword(10,1);
}

4 (3 Votes)
0
4
3

                                    Random rnd = new Random();
int month  = rnd.Next(1, 13);  // creates a number between 1 and 12
int dice   = rnd.Next(1, 7);   // creates a number between 1 and 6
int card   = rnd.Next(52);     // creates a number between 0 and 51

4 (3 Votes)
0
0
0
Loopio 100 points

                                    private static Random random = new Random();

public static string RandomString(int length)
{
    const string chars = "AaBbCcDdEeFfGgHhIiJjKkLlMmNnOoPpQqRrSsTtUuVvWwXxYyZz0123456789";
    return new string(Enumerable.Repeat(chars, length)
      .Select(s => s[random.Next(s.Length)]).ToArray());
}

public static string[] RandomStrings_Type1(int strLength, int arraySize)
{
	const string chars = "AaBbCcDdEeFfGgHhIiJjKkLlMmNnOoPpQqRrSsTtUuVvWwXxYyZz0123456789";
  	string[] strArray = new string[arraySize];
    for (int i = 0; i < strArray.Length; i++)
    {
  		string randomString = new string(Enumerable.Repeat(chars, length)
                                     .Select(s => s[random.Next(s.Length)]).ToArray());
      	strArray[i] = randomString;
    }
  	return strArray;
}

public static List<string> RandomStrings_Type2(int strLength, int listSize)
{
	return RandomStrings_Type1(strLength, listSize).ToList();
}

0
0
4.14
7

                                    private static Random random = new Random();
public static string RandomString(int length)
{
    const string chars = "ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789";
    return new string(Enumerable.Repeat(chars, length)
      .Select(s => s[random.Next(s.Length)]).ToArray());
}

4.14 (7 Votes)
0
Are there any code examples left?
Create a Free Account
Unlock the power of data and AI by diving into Python, ChatGPT, SQL, Power BI, and beyond.
Sign up
Develop soft skills on BrainApps
Complete the IQ Test
Relative searches
how to make a random letter generator in c# alphanumeric string generator c# how to generate a random character in c# generate random letter c# randomdly string in c# generate random string of numbers c# c# random numbrer c sharp generate random alphanumeric random string and number generator c# print random string from string c# return random element from string c# how to generate random strings C# how to generate random string C# C# string random generator how to generate a random string with 13 carachter in c# c# random using random number of string C# get random letter c# c# random string of length C# how to randomize a string c# how to generate a random number c sharp random number c# generate random number c# generate 4 digit random number csharp random string how to make a random number generator with string in c# generate random string c sharp c# random from string C# random string chars c# create random random string word c# how to genarate random string c# generate random letters c# get random alphanumeric string c# random alphanumeric C# display random string in c# how to random string in c# hoe to pick a random string in c# random between string c# generate random string c# core generate random number in c# with pattern random in c# assign random value to string c# random number with c# how to get a random string in c# generate unique random alphanumeric string c# generate random alphanumericstring c# C# generate random string token random number c# function .net generate random number c# int random c# generate random letter how to genarate random number in c# generate random string array c# code to generate random numbers in c# create random generator c# random for stringin c# how to get random item from string C# .net create random string c# functinon that generate random string of alphanumeric character how to generate random string in asp.net using c# c# get random letter from string generate random phone number c# c# how to generate random number control random numbers in c# random number generator with c# how to generate a random number in c# random number in c# random letter c# how to generate random code in c# how to select random character from string in c# generate a random string c# how to get random string value from a variable c# c# secure random string generator how to add random numbers to c# function to generate random string c# existing function to generate random string in c# how to generate a random alphanumeric string in c# c# random num get a random letter c# how to get random values in c# getting random letter c# random c# code c# random number generator c# get random number random function c# generate random 4 digit number c# using random in c# c# secure random alphanumeric string generate alphanumeric random number in c# c# generate random string of length generate random alphanumeric password c# how to generate random number c# c# generate random string of letters and numbers c# random int random alphanumeric generator how to genrate random string in c# how to pick a random number in c# c# random letter how to get random number in C# c# random randomize string c# c# string random ID random strings c# random c# how to get a random string with numbers c# c# code random generator c# random string from character generate random string with format c# c# string random .net random string generator c# how to make code pick random strings How to make a random number c# random number c# c# convert random to string c# create random number random number generator c# c# random number random string generator c# .net framework c# net generate randon string c# print random string choose random number in c# how to generate a random numer in c# generate 6 digit random alphanumeric in c# string random generator c# random string genetion c# how to make a random string c# generate random single alphanumeric character C# generate random single char c# generate random characters c# c# take rabdom char from guiid random text string c# create a random string in c# generate string random c# random letter generator C# how to print random string in c# random string generator c# considering the string that i have C# random with length c# random texty c# randomly generate string based on other strings c# gen random string c# generate a 16 character random ID for loop c# generate a 16 character random ID using random character c# random string guid c# generate string c# can you enter random letters to c# C# generate to String c# random alphanumeric string 8 digit dotnet core generate aleatorio characteres c# random string value how to generate alphanumeric in c# c# generate random character string c# random sting C# how to do Random strings C# how to get a random string and output rancom abc c# array linq generate random string random text C# alphanumeric part number generator in c# generate random strings c# c# generate random alphabet c# random char x times c# random char in a string c# random char generator random char generator c# lettere generator C# letter generator C# random alphabet generator c# cryptography random string letters only cryptography random string alphabet how to get a ramdom letter from a text in c# c# random number and letter generator generate 5 digit random number c# helper method how to do random in c# with strings C# to generate 6 character code c# random character how to return a random string with specific characters in C# how to use regex to generate a random name with 2 numbers at the end using c# get random alphanumeric string C3 how to generate random strings with numbers in c# c# create a random string random string code in c# extract random char from a word c# c# pick random character position in number C# make an array with random numbers generate random sting in c# c# new random random number generator with alphanumeric in c# c# random string with special characters how to generate a random string in c# random characters C# generate 6 random characters C# how to do random in c# c# create random string out of characters Randomize 32 numbers c# csharp generate random string C# generate random 6 characters all lowercase generate alphanumeric random number c# c# convert 2 digit random number c# random alphanumeric windows c# generating random string get random int ids in c# 7-digit alphanumeric sequence number C# how to generate 7-digit alphanumeric sequence number in c# hoe to generate 7-digit alphanumeric sequence number in c# c# generate random letters c# random unique string how to get the random alphabetic string using c#.net how to get the random string using c#.net string random c# c# generate random no char has random number c# generate random string static string RandomString(int size, bool lowerCase = false) net random 5 character generator alphanumeric string c# hor to generate unigue 6 character alphanumeric characters C# how to generate alphanumeric token c# c# generate random ip C# create random string C# generate random short c# random numer of 4 char random number between 0 an 10 in c# c# random numbers and strings c# random between how to create a random string in c# c# generate random character c# generate random string from list with set amount of characters how to get random int in c# c# how to use Math.Random() c# generate random 30 characters generate a random 8 karakter code c# c# use Random random alphanumeric asp.net c# generate random key from string c# add random letter from list to string 8 lenght token c# dot net:generate random string random alphanumeric object asp.net core random alphanumeric object asp.net c# string random generator asp.net core c# random generated string c# random generated data string generate random text c# c# random number how mant times c# random between 0 and 10 C# random string from numbers C# generate 10 number string random string from strings c# C# return random string generate random int between two numbers c# c# code that generates a random integer from 25 to 100 c# random between 1 and 6 c# random number generator min max generate random 16 character string c# random int c# random integer number in c# how to make a string that says a random numbe a - C# generate random string csharp c sharp random inte generate unique string according to the number c# c# how to do print string with random generate stirn grandom c# fasrt generate stirn grandom c# generate a random string in C# generate 11 digit unique aplpanumeric c# generate 11 digit alphanumeric random number in c# c# random string generator c# random to int c# get random number between 1 and 10 a method in class to generate random string in c# class a method to generate random string in c# asp.net c# random string random number c# c# generate unique alphanumeric string code c# math.random generate 15 digit string in c# string generator c# c# getting a random number c# how to make a random gen to int ramdom string c# C# how to generate random string with only letters and numbers generate random string in c# within range randomly generate string c# get random int c# c# to string generator how to pick a random number c# c# get a random number select a random number c# If you want to generate a random integer number you need to call the c# string auto generator c# create randomly generated string c# generate a random integer value from 25 to 100 C# c# random number between 1 and 10 c# generate a random number between 1 and 10 c# randm string c# random number characters c# generate random string a - z 1 - 9 xamarin android generate random string random generator string c# C# random stirng c# what int is generate number randomizer visual studio c# generate random number c# c# generate alphanumeric string genersate random characters array in c# generate a random alphanumeric string in C# how to generate random letters in C# string randomizer c# generate random alphanumeric string c# HOW can i generate random alphanumeric string in c# WITH 8 BIT COLOR c# generate random sting C# + generate random string cretae random string c# c# generate random string alphanumeric c# generate random code random C# strings csharp get random number from string stack overflow how to generate random strings c# using random with strings in c# generate string of random characters C# c# generate random string in range random string+numeric generator c# how to print multiple rows from a random generated alphanumeric to a textbox c# how to print multiple rows from a random generated alphanumeric c# create random string c# c# generate unique alphanumeric string generate random two string, chars and numeric c# random alphanumeric generator dewey decimal call number c# random alphanumeric generator c# four letters random alphanumeric generator c# generate random string in c# random number and string generator algorithm c# get a random string c# how to generate and show a randoms string in c# how to generate random string c# how to generate random string with 40 cacarters c# how to generate random string in c# .net random string c# how to get random string dotnet create random string How to put a random into a string in c# c# random text c# random string.Compare C# get random string generate five characters c# function make a random 64character string c# random aplhpanumeric string generator c# random character generator c# random letters generatr c# c# random char and number generator c# random only character random range string syntax c# how to make random text 'in c# c# get random text generating reference number using two alphabets and acceding number asp.net random 10 letters generator c# random text generator c# how to generate random numbers and letters in C# generate random string c# with fix length c# check string if random characters or not c# convert string to random characters and back c# generate random alphanumeric string generate a 8 length string from a list of random char values c# return 8 random values in a list of char c# randomstring generator c# generate string out of certain letter c# c# random alphanumeric string make random text generator C# random string generator c# .net c# random 10 char string c# string generator c# random strings generate radom string c# random string generator c# random string generator c# c# random string from string[] c# create string random C# MVC method for random number and letters mixed c# create random string of letters create a random string of numbers c# c# generate int with amount of charachter generate random long string c# c# get random strign get random string c# random string generator in C# random alphanumeric strings c# generate random code c# random alphanumeric object no repeat c# random alphanumeric object c# radom alphanomeric object c# .net generate random string random string in c# random string numbers c# random string c# c# generate random string generate random string c# c# random string
Made with love
This website uses cookies to make IQCode work for you. By using this site, you agree to our cookie policy

Welcome Back!

Sign up to unlock all of IQCode features:
  • Test your skills and track progress
  • Engage in comprehensive interactive courses
  • Commit to daily skill-enhancing challenges
  • Solve practical, real-world issues
  • Share your insights and learnings
Create an account
Sign in
Recover lost password
Or log in with

Create a Free Account

Sign up to unlock all of IQCode features:
  • Test your skills and track progress
  • Engage in comprehensive interactive courses
  • Commit to daily skill-enhancing challenges
  • Solve practical, real-world issues
  • Share your insights and learnings
Create an account
Sign up
Or sign up with
By signing up, you agree to the Terms and Conditions and Privacy Policy. You also agree to receive product-related marketing emails from IQCode, which you can unsubscribe from at any time.
Creating a new code example
Code snippet title
Source