copy array string to by byte array
-
I have a array of string .How can I place the array to byte String[] mm = {"A","B","C"}; byte[] by = new byte[3]; by = mm; This one make error How can solve this problem.
Continue...
-
I have a array of string .How can I place the array to byte String[] mm = {"A","B","C"}; byte[] by = new byte[3]; by = mm; This one make error How can solve this problem.
Continue...
Hi YOu are assigning string values to byte, thats why its giving error. You can use following code String[] mm = {"A","B","C"}; byte[] by = new byte[3]; for (int i = 0; i < mm.Length; i++) { by[i] = Convert.ToByte(mm[i]); }
-
I have a array of string .How can I place the array to byte String[] mm = {"A","B","C"}; byte[] by = new byte[3]; by = mm; This one make error How can solve this problem.
Continue...
Generally you can't convert a string to a byte. For example a string like "Hello world!" does not fit into a single byte. If you have a special case where all strings always are exactly one character long, you can get that character and get the character code for it. The character code is still 16 bits, though, while a byte only is 8 bits. To store a character code in a byte only works if the characters are all only ASCII characters, so that you can safely discard the top 8 bits of the character code.
--- Year happy = new Year(2007);