Originally Posted by
snip3r8
For example
Code:
bool check = true;
for(int i =0;i < 2;i++)
{
check = !check;
if(check)
{
Console.WriteLine("Hello World");
}
}
this will print "Hello World" twice (but only sometimes).
This claim was amazing. So amazing I downloaded Monodevelop to try it myself!
Here is my code:
Code:
using System;
namespace Test
{
class MainClass
{
public static void Main (string[] args)
{
int wrong = 0;
for (int j = 0; j < 500000; j++)
{
bool check = true;
int testVal = 0;
for(int i =0;i < 2;i++)
{
check = !check;
if(check)
{
testVal++;
}
}
if (testVal == 2)
{
wrong++;
}
}
Console.WriteLine("There were " + wrong + " wrong");
}
}
}
This prints:
Which is exactly what I would expect. I can't make it do the weird stuff you mentioned.
Paul
Bookmarks