FCL Many methods return values are byte arrays that contain characters instead of returning a string, and such methods are included in the following class:
The byte array returned by these methods contains usually ASCII-encoded or Unicode-encoded characters, and many times we may need to convert such a byte array to a string.
Solution
Converts a byte array that contains ASCII-encoded characters into a complete string, using the following methods:
The GetString method of the ASCIIEncoding class converts the 7-bitsascii character in a byte array to a string; Any value greater than 127 will be converted to two characters. In the System.Text namespace you can find the ASCIIEncoding class and find the GetString function of the class you can also find that the function has several overloads to support some additional parameters. An overloaded version of this method can also convert a subset of characters from a byte array to string.
The GetString method of converting a byte array to string can be found in the UnicodeEncoding class in the System.Text namespace, which converts a byte array containing 16-bitsunicode characters to a string. Like the GetString method of the ASCIIEncoding class, this method also contains an overloaded version that converts a particular part of a byte array to string.
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.