CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 2 of 2

Thread: Random

  1. #1
    Join Date
    Jun 2016
    Posts
    1

    Random

    hi,

    how do I get the generated int random seed from this code?
    Code:
    ranNum = new Random((int)DateTime.Now.Ticks);
    I tired something like this but it returns "Sytem.Random" instead of number
    Code:
    Console.WriteLine(ranNum.ToString());

  2. #2
    Join Date
    Feb 2008
    Posts
    108

    Re: Random

    Try:
    Code:
                long Seed = DateTime.Now.Ticks;
                Random R = new Random((int) Seed);
                int Ri = R.Next();
    Ri can then be printed out.
    Developing using:
    .NET3.5 / VS 2010

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured