tags:

views:

48

answers:

2

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(myByteArray);

How else can I achieve this?

+1  A: 
string text = Encoding.UTF8.GetString(myByteArray,0,myByteArray.Length);

Works in SL4, don't know about anything earlier.

Stephan
+3  A: 

You can do:

string text = UTF8Encoding.UTF8.GetString(yourByteArray, 0, yourByteArray.Length);

Silverlight 3 and 4 only support that override.

Frédéric Hamidi