I have a random string generator but it's not erasing the string every time it creates a new random one. Instead it's just adding to the old one. The code snippet is inside of a method that requires a boolean value (rText) to decide if it should use random text or not. The method is called on timer tick; so any help is appreciated.

if (rText)
            {
                mts = "";

                for (int i = 0; i < size; i++)
                {
                    ch = Convert.ToChar(Convert.ToInt32(Math.Floor(26 * random.NextDouble() + 65)));
                    builder.Append(ch);
                }

                mts = builder.ToString().ToLower();
            }

Figured it out; replaced line 3 with builder.Clear();

Thanks anyways guys.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.