When you need to reset a stream to beginning (e.g. MemoryStream) is it best practice to use
stream.Seek(0, SeekOrigin.Begin);
or
stream.Position = 0;
I’ve seen both work fine, but wondered if one was more correct than the other?
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.
Use
Positionwhen setting an absolute position andSeekwhen setting a relative position. Both are provided for convenience so you can choose one that fits the style and readability of your code. AccessingPositionrequires the stream be seekable so they’re safely interchangeable.