how to convert char[] to byte[] without loss of data
-
Hi, How can I convert char[] to byte[] without loss of data? Regards, Hemant.
-
Hi, How can I convert char[] to byte[] without loss of data? Regards, Hemant.
How can I convert char[] to byte[] without loss of data? typecast it
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
cheers, Alok Gupta VC Forum Q&A :- I/ IV Support CRY- Child Relief and you
-
Hi, How can I convert char[] to byte[] without loss of data? Regards, Hemant.
-
Hi, How can I convert char[] to byte[] without loss of data? Regards, Hemant.
That depends on how you want to convert it. The char data type is a 16 bit unicode character. Unless you have restricted the characters to use only ASCII characters, each character can not be converted to a byte. If you want to convert the string to it's encoded format, you can use the GetBytes method of the encoding you want to use. Example:
byte[] data = Encoding.UTF8.GetBytes(theChars);
--- b { font-weight: normal; }