hi
i cant seem to get this work!
it only uses the letters up to the specified number, but i want it to use the letters that has been specified maximum, ie if the letter was z it should use all letters up to and including z
whats the problem?
Code:int maximumLength = 9; string minLetter = "a"; string maxLetter = "z"; string alphabet = "abcdefghijklmnopqrstuvwxyz"; string theMainString = null; int minNum = 0; string finalResult = null; //MessageBox.Show(DoRandThing(9,10,'a','h')); //return; for (int i = 0; i < alphabet.Length; i++) { if (alphabet[i].ToString().Equals(minLetter)) { for (int counter = i; counter < alphabet.Length; counter++) { if (!alphabet[counter].ToString().Equals(maxLetter)) { theMainString = theMainString + alphabet[counter].ToString(); } //if we found the last letter, break out the loop! if(alphabet[counter].ToString().Equals(maxLetter)) { theMainString = theMainString + alphabet[counter].ToString(); break; } } } } int randomNumber = ran.Next(minNum, maximumLength); if (randomNumber == 0) { randomNumber = 1; } for (int counter = 0; counter < randomNumber; counter++) { finalResult = finalResult + theMainString[ran.Next(minNum, maximumLength)].ToString(); } MessageBox.Show(finalResult.ToString());




Reply With Quote