[Mono-list] StreamReader.Peek() and support for character devices
Tony Garnock-Jones
tonyg@lshift.net
Tue, 27 May 2003 23:33:17 +0100
(Here's a small bit of code that shows what I mean:)
// When this runs, type 123 and press return
// I would expect it to process those characters
// and then wait for more - but it exits
// after the newline character
using System;
using System.IO;
using System.Text;
public class rtcs2 {
public static void Main(String[] args) {
while (true) {
int ch = P();
if (ch == -1) {
// No more characters available.
// End of file?
System.Console.WriteLine("bye!");
break;
}
ch = R();
System.Console.WriteLine("read: "+
ch+" ("+((char)ch)+")");
}
}
private static int P() {
int r = System.Console.In.Peek();
System.Console.WriteLine("Peeking: "+r);
return r;
}
private static int R() {
int r = System.Console.In.Read();
System.Console.WriteLine("Reading: "+r);
return r;
}
}