I'm trying to convert a byte array to a string in Silverlight, but I get the following compilation error:
'System.Text.Encoding.GetString(byte[])' is inaccessible due to its protection level
This is the method that I'm using:
string text = UTF8Encoding.UTF8.GetString(my开发者_开发知识库ByteArray);
How else can I achieve this?
You can write:
string text = UTF8Encoding.UTF8.GetString(yourByteArray, 0, yourByteArray.Length);
Silverlight 3 and 4 only support that override.
string text = Encoding.UTF8.GetString(myByteArray,0,myByteArray.Length);
Works in SL4, don't know about anything earlier.
You May use Inicode encoding also,
String text=(new UnicodeEncoding()).GetString(barray, 0, barry.Length)
By this way you are able to get as string from byte[],
vice versa by
Byte[] myarray=(new UnicodeEncoding()).getBytes(Stringexpressin);
精彩评论