How to copy a string into a byte[]
-
Hello, I want to copy a string into a byte[] array. string has a method ToCharArray that returns a char[] but that`s just not good enough, since a char is 2 bytes. Is there a quick and easy way to accomplish this? In unmanaged C++ I could just do a memcpy or memmove into a designated BYTE array, is there something similar I can use in C#? Thanks for your feedback, Davy
-
Hello, I want to copy a string into a byte[] array. string has a method ToCharArray that returns a char[] but that`s just not good enough, since a char is 2 bytes. Is there a quick and easy way to accomplish this? In unmanaged C++ I could just do a memcpy or memmove into a designated BYTE array, is there something similar I can use in C#? Thanks for your feedback, Davy
-
Hello, I want to copy a string into a byte[] array. string has a method ToCharArray that returns a char[] but that`s just not good enough, since a char is 2 bytes. Is there a quick and easy way to accomplish this? In unmanaged C++ I could just do a memcpy or memmove into a designated BYTE array, is there something similar I can use in C#? Thanks for your feedback, Davy
-
Hello, I want to copy a string into a byte[] array. string has a method ToCharArray that returns a char[] but that`s just not good enough, since a char is 2 bytes. Is there a quick and easy way to accomplish this? In unmanaged C++ I could just do a memcpy or memmove into a designated BYTE array, is there something similar I can use in C#? Thanks for your feedback, Davy
-
System.Text.Encoding. A byte sequence means nothing without the information on how to map the byte sequence to characters. This is what the Encoding classes do.