If you can convert this to VB.NET (which is trivial), I would say that itβs good for you to go (if you canβt, use this or any other tool that is worth it):
/// <summary> /// The Typing monkey generates random strings - can't be static 'cause it a monkey. /// </summary> /// <remarks> /// If you try hard enough it will eventually type some Shakespeare. /// </remarks> class TypingMonkey { private const string legalCharacters = "ABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890"; static Random random = new Random(); /// <summary> /// The Typing Monkey Generates a random string with the given length. /// </summary> /// <param name="size">Size of the string</param> /// <returns>Random string</returns> public string TypeAway(int size) { StringBuilder builder = new StringBuilder(); char ch; for (int i = 0; i < size; i++) { ch = legalCharacters[random.Next(0, legalCharacters.Length)]; builder.Append(ch); } return builder.ToString(); } }
Then you only need to:
TypingMonkey myMonkey = new TypingMonkey(); string randomStr = myMonkey.TypeAway(size);
JohnIdol
source share