Is there any function in c# equivalent to C’s stdio function ungetc() ?
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Not that I know of; for some scenarios, you could use something like a
StreamReaderand usePeek?However, I don’t think you can push arbitrary data back into the stream unless you are using something like
MemoryStreamand can thus monkey with the data.Even if you have a
Streamthat is both readable and writeable (rare), then there is still only one cursor, so you would need to be careful to reset the position after writing (so it would need to be seekable too; again, not common); however, this is not robust – some streams (the network streams in TCP, for example) would treat the write as a ‘send this to the other machine’, and it would never be returned by a read. And it isn’t seekable ;-p