for loop = weird [Archive] - C Board

PDA

View Full Version : for loop = weird


-KEN-
11-11-2001, 09:58 AM
Ok, has anyone ever tried for loops in C#? test out this code:


using System;

class MyClass
{
public static void Main(String[] args)
{
int x;
for(x=0;x<10;x++)
System.Write(x);
}
}

if you notice, the output is 123456789

not exactly like C/C++/Java...hmmm, it'll be hard to remember to always make the number one higher than you want it to go to.

nvoigt
11-11-2001, 10:39 AM
As I notice, your code does not print anything, it doesn't even compile.

This


using System;

class MyClass
{
public static void Main(String[] args)
{
int x;
for(x=0;x<10;x++)
System.Console.Write(x);
}
}


however produces "0123456789" as you would expect it.

-KEN-
11-11-2001, 10:58 AM
*note to self: I'm a moron*

Sorry, I was trying to write it off the top of my head...

and I did this yesterday on my upstairs computer, and it however read "123456789", I swear! but now it doesn't...damnit, I'm senile. Oh well.