public int Read() { char?c; lock (_stdInLock) { if (StdIn.Length > 0) { c = StdIn[0]; StdIn.Remove(0, 1); } else { c = null; } } return(c.Value); }
public string ReadLine() { if (StdIn.Length == 0) { // End of input return(null); } StringBuilder line = new StringBuilder(); lock (_stdInLock) { while (StdIn.Length > 0 && (line.Length == 0 || line[line.Length - 1] != '\n')) { line.Append(StdIn[0]); StdIn.Remove(0, 1); } } return(line.ToString().Trim()); }