G
Guest
for the following code snippet:
int k;
char c;
while (true)
{
k = Console.Read ();
if (k == -1) break;
c = (char) k;
Console.WriteLine ("Echo: {0}", c);
}
Console.WriteLine ("Done");
jljkj
Echo: j
Echo: l
Echo: j
Echo: k
Echo: j
Echo:
Echo:
so this is result after I typing "jljkj" then "enter" in the console in XP.
What is going on here!? I just don't understand the program's performance?
Read() is suppose to read in a character? or a stream!? But even it can read
in a stream, how can it separates the character in the stream and print them
out separately according to code above!? I am new to C#. Thanks for your
help!!!
int k;
char c;
while (true)
{
k = Console.Read ();
if (k == -1) break;
c = (char) k;
Console.WriteLine ("Echo: {0}", c);
}
Console.WriteLine ("Done");
jljkj
Echo: j
Echo: l
Echo: j
Echo: k
Echo: j
Echo:
Echo:
so this is result after I typing "jljkj" then "enter" in the console in XP.
What is going on here!? I just don't understand the program's performance?
Read() is suppose to read in a character? or a stream!? But even it can read
in a stream, how can it separates the character in the stream and print them
out separately according to code above!? I am new to C#. Thanks for your
help!!!