Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C#
  4. How to Get AutoGenerate Code with Strings and Numbers in C#

How to Get AutoGenerate Code with Strings and Numbers in C#

Scheduled Pinned Locked Moved C#
csharptutorialquestion
4 Posts 4 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • C Offline
    C Offline
    ChandrakanthGaddam
    wrote on last edited by
    #1

    Hi, This is from CHandra My Questions in How can i get AutoGenerate alpha numerics with combination of strings and Numbers. Can any give me some suggestion on or any code is there in C# please send me Thanks and Regards Chandrakanth

    M D 2 Replies Last reply
    0
    • C ChandrakanthGaddam

      Hi, This is from CHandra My Questions in How can i get AutoGenerate alpha numerics with combination of strings and Numbers. Can any give me some suggestion on or any code is there in C# please send me Thanks and Regards Chandrakanth

      M Offline
      M Offline
      musefan
      wrote on last edited by
      #2

      How about...

      string GetRandomString(int length)//length of random string
      {
      System.Text.StringBuilder sb = new System.Text.StringBuilder(length);
      Random rnd = new Random();
      for(int i = 0; i < length; i++)
      {
      sb.Append((char)rnd.Next(33, 127));
      }
      return sb.ToString();
      }

      Life goes very fast. Tomorrow, today is already yesterday.

      modified on Wednesday, July 15, 2009 9:08 AM

      L 1 Reply Last reply
      0
      • C ChandrakanthGaddam

        Hi, This is from CHandra My Questions in How can i get AutoGenerate alpha numerics with combination of strings and Numbers. Can any give me some suggestion on or any code is there in C# please send me Thanks and Regards Chandrakanth

        D Offline
        D Offline
        dan sh
        wrote on last edited by
        #3

        Guid.NewGuid().ToString("N");

        1 Reply Last reply
        0
        • M musefan

          How about...

          string GetRandomString(int length)//length of random string
          {
          System.Text.StringBuilder sb = new System.Text.StringBuilder(length);
          Random rnd = new Random();
          for(int i = 0; i < length; i++)
          {
          sb.Append((char)rnd.Next(33, 127));
          }
          return sb.ToString();
          }

          Life goes very fast. Tomorrow, today is already yesterday.

          modified on Wednesday, July 15, 2009 9:08 AM

          L Offline
          L Offline
          Luc Pattyn
          wrote on last edited by
          #4

          musefan wrote:

          System.Text.StringBuilder sb = new System.Text.StringBuilder(length);

          ftfy. I improved the performance a bit. :)

          Luc Pattyn [Forum Guidelines] [My Articles]


          The quality and detail of your question reflects on the effectiveness of the help you are likely to get. Show formatted code inside PRE tags, and give clear symptoms when describing a problem.


          1 Reply Last reply
          0
          Reply
          • Reply as topic
          Log in to reply
          • Oldest to Newest
          • Newest to Oldest
          • Most Votes


          • Login

          • Don't have an account? Register

          • Login or register to search.
          • First post
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • World
          • Users
          • Groups