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. random number generation

random number generation

Scheduled Pinned Locked Moved C#
csharphelptutoriallounge
5 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.
  • G Offline
    G Offline
    givya
    wrote on last edited by
    #1

    i wanna know how to create random numbers in c#. in my application i need to provide a default password if the user forgets the password. i wanna give this default password in the form of random numbers. pls help...

    S R H 3 Replies Last reply
    0
    • G givya

      i wanna know how to create random numbers in c#. in my application i need to provide a default password if the user forgets the password. i wanna give this default password in the form of random numbers. pls help...

      S Offline
      S Offline
      SeMartens
      wrote on last edited by
      #2

      Hi, the .NET framework provides a Random-class. Have a look here: http://msdn.microsoft.com/en-us/library/system.random.aspx[^] Regards Sebastian

      It's not a bug, it's a feature! Check out my CodeProject article Permission-by-aspect. Me in Softwareland.

      1 Reply Last reply
      0
      • G givya

        i wanna know how to create random numbers in c#. in my application i need to provide a default password if the user forgets the password. i wanna give this default password in the form of random numbers. pls help...

        R Offline
        R Offline
        Rajesh R Subramanian
        wrote on last edited by
        #3

        Hello Givya, Have you tried searching[^]?

        It is a crappy thing, but it's life -^ Carlo Pallini

        1 Reply Last reply
        0
        • G givya

          i wanna know how to create random numbers in c#. in my application i need to provide a default password if the user forgets the password. i wanna give this default password in the form of random numbers. pls help...

          H Offline
          H Offline
          himanshu2561
          wrote on last edited by
          #4

          Hi Use Random class like

          Random r = new Random();

          givya wrote:

          in my application i need to provide a default password if the user forgets the password

          IMO ,If possible try to provide forgot password functionality like [Hint Question or Alternate Email]...

          himanshu

          G 1 Reply Last reply
          0
          • H himanshu2561

            Hi Use Random class like

            Random r = new Random();

            givya wrote:

            in my application i need to provide a default password if the user forgets the password

            IMO ,If possible try to provide forgot password functionality like [Hint Question or Alternate Email]...

            himanshu

            G Offline
            G Offline
            givya
            wrote on last edited by
            #5

            I gave the following code to generate the random string(searched it on internet). private string RandomString(int size, bool lowerCase) { StringBuilder builder = new StringBuilder(); Random random = new Random(); char ch; for (int i = 0; i < size; i++) { ch = Convert.ToChar(Convert.ToInt32(Math.Floor(26 * random.NextDouble() + 65))); builder.Append(ch); } if (lowerCase) return builder.ToString().ToLower(); return builder.ToString(); } Bt its giving the following error: A using namespace directive can only be applied to namespaces; 'System.Text.StringBuilder' is a type not a namespace I hav used this also: "using System.Text.StringBuilder;" Pls help

            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