What is the C# equivalent of the following C code:
while((c = getchar())!= EOF)
putchar(c);
I know getchar() and putchar() are going to be replaced by Console.Read and Console.Write respectively but what about the EOF. Especially keeping in mind, C# works with unicode and C with ASCII, what are the implications of that ??
Console.Read() returns -1 on EOF (coincidentally, EOF is defined as
-1on most platforms).You can do:
Also, C# works natively with
UNICODEin the same way that C works natively withASCII, i.e. there are no more implications. System.Char represents an UCS-2UNICODEcharacter, which also fits into anint, so everything will be all right.