how to convert IEnumerable to byte[] in c#
is there any option in c#. the IEnumerable may contain large data
Know the answer? Post it — somebody with the same question will find it here.
Sign in to answer this question
It is the same account you read, post and publish with — and you will come straight back to this page.
Kunjahamed PPosted Jan 21, 2020, 6:24 PM
This will use
UTF8as encoding for the bytes. You might need to use a different encoding depending on what you want to do with the bytes afterwards.Note that - as written above - this is not directly reversible because you lose the information where one
stringends and where the next one starts.If you want to, you could a
NewLine(or any other identifier that you could use afterwards to split on) after each string to keep them separate:Rajanikant HawaldarPosted Jan 21, 2020, 5:50 PM