Timepass... Fix the code...

by rahul 1/27/2009 12:22:07 PM

Create a C# Console application, and paste the following code in the Main method...

          for (int i = 0; i < 5; i++)
          {
              //Generating a Random number between 0 and 100000
              int intRandomElement;
              Random r = new Random();
              intRandomElement = r.Next(1, 100000);
              Console.WriteLine(intRandomElement);
          }

 

If you run this code in debug mode, you should be able to get the output as expected. But if you run the same application without debugging, you would see a different result. Can you fix the code?

Enjoy!
Rahul



Tags: , ,

.NET | C# | Timepass

blog comments powered by Disqus

Comments

Rahul Soni

Rahul Soni  Twitter

 LinkedIn

 Facebook

 Email me



Vivek Kumbhar

Vivek Kumbhar  Twitter

 LinkedIn

 Facebook

 Email me


Stack Exchange

profile for Vivek at Server Fault, Q&A for system administrators and IT professionals

profile for Rahul Soni at Stack Overflow, Q&A for professional and enthusiast programmers

Calendar

<<  February 2012  >>
MoTuWeThFrSaSu
303112345
6789101112
13141516171819
20212223242526
2728291234
567891011

View posts in large calendar

All Items
Sign in

Disclaimer

The opinions expressed herein are my own personal opinions and do not represent my employer's view in any way.
© Copyright 2012, Rahul Soni

Powered by BlogEngine.NET 1.4.5.0