Today, I use a memory stream :
new MemoryStream(Encoding.UTF8.GetBytes(str))
Is there a simpler / better way ?
Thank you !
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.
That’ll do it; there not really anything more direct than that, since you need the bytes (for the
StreamAPI), hence need to go via anEncoding.Note, however, that many APIs that take text-based data via a
Streamwill also accept aTextReader, and thusnew StringReader(str)will be more direct.