Convert SQL binary data to string in C #

Does anyone have sample code for converting from binary data to a string in C #?

+3
source share
2 answers

It sounds like you just need to decode binary data. So you need an encoding (e.g. utf-8 or unicode).

Example:

var textFromBinary = System.Text.Encoding.UTF8.GetString(myBinaryData);
+3
source

If your binary data is stored in an array byteand you want to convert it to Base64 encoding, you can use the Convert.ToBase64Stringmethod:

var base64String = Convert.ToBase64String(yourBinaryDataHere);
+1
source

Source: https://habr.com/ru/post/1749232/


All Articles