title: Generate random string
body: <blockquote>
    <p><strong>Possible Duplicate:</strong><br>
    <a href="https://stackoverflow.com/questions/1122483/c-sharp-random-string-generator">c# random string generator</a>  </p>
  </blockquote>
  
  
  
  <p>I need to generate a random string with a given length. This is my code so far. The problem is the random string is like "RRRRRR" or "SSSSS" The same letter every time. Just when i restart the app the letter change. I need something like "asrDvgDgREGd"</p>
  
  <pre><code>    public string GenerateChar()
      {
          Random random = new Random();
  
          return Convert.ToChar(Convert.ToInt32(Math.Floor(26 * random.NextDouble() + 65))).ToString();
      }
  
      public string GenerateChar(int count)
      {        
          string randomString = "";
  
          for (int i = 0; i &lt; count; i++)
          {
              nahodneZnaky += GenerateChar();
          }
  
          return randomString;
      }
  </code></pre>