Create A Random String


	//********************************************
	//********************************************
	//********** GENERATE RANDOM STRING **********
	//********************************************
	//********************************************
	private string GenerateRandomString (int length)
	{
		int Count;
		const string STRING_CHARACTER_SET = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz";
		string OutputString = "";

		System.Random rand = new System.Random();		//Creates seed value from system clock if no seed supplied

		for (Count = 0; Count < length; Count++)
		{
			OutputString += STRING_CHARACTER_SET[rand.Next(0, STRING_CHARACTER_SET.Length)];
		}

		return (OutputString);
	}

 

Feel free to comment if you can add help to this page or point out issues and solutions you have found. I do not provide support on this site, if you need help with a problem head over to stack overflow.

Comments

Your email address will not be published. Required fields are marked *