C # Java PushbackReader equivalent unread ()

I am looking for the C # equivalent for the unread () Java method.

the C # equivalent for PushbackReader is supposedly System.IO.StreamReader, but StreamReader does not have an β€œunread ()” equivalent. It has Peek (), but there is no way to return a character to the stream.

Java Code:

// putBackChar puts the character back onto the stream // adjusts current line number if necessary private void putBackChar() { if (ch == '\n') currentLine--; try { in.unread((int) ch); } catch (IOException e) {} } 
+4
source share
1 answer

Peek reads a character without pushing it out of the stream, so you will not need to return it to the stream.

+2
source

All Articles