Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR CSHARP

using randomly chars to build a string

// C# program to generate random strings
using System;

class GFG{

static void Main()
{

	// Creating object of random class
	Random rand = new Random();

	// Choosing the size of string
	// Using Next() string
	int stringlen = rand.Next(4, 10);
	int randValue;
	string str = "";
	char letter;
	for (int i = 0; i < stringlen; i++)
	{

		// Generating a random number.
		randValue = rand.Next(0, 26);

		// Generating random character by converting
		// the random number into character.
		letter = Convert.ToChar(randValue + 65);

		// Appending the letter to string.
		str = str + letter;
	}
	Console.Write("Random String:" + str);
}
}
 
PREVIOUS NEXT
Tagged: #randomly #chars #build #string
ADD COMMENT
Topic
Name
4+4 =