Error: System.Text.Encoding 'does not contain a definition for' Default '

I get the following error: 'System.Text.Encoding' does not contain a definition for 'Default' when I try to use the default Encoding method through

var str2 = System.Text.Encoding.Default.GetString(bytearray); 

Through MSDN, I found out that there is a Default method in System.Text.Encoding, then why am I getting this error? MSDN refrence for Default here: enter link description here

please help me.

+4
source share
2 answers

Encoding.Default refers to the default ANSI code page in standard windows inherited from time depth. Even in ordinary windows, Encoding.Default not recommended. There is no such concept on a Windows phone, therefore: use the correct encoding; which usually means .UTF8 .

The Windows phone does not use the same .NET platform as Windows, although they are very similar and will compile a lot of code the same way.

+6
source

On the MSDN page that you linked, if you expand the Other Versions drop-down list, you will see that Silverlight (and therefore Windows Phone) is not listed. Similarly, if you look at the members of the Silverlight Encoding version, you will not find Default : http://msdn.microsoft.com/en-us/library/System.Text.Encoding_properties(v=vs.95).aspx

Use Encoding.UTF8 instead:

 var str2 = System.Text.Encoding.UTF8.GetString(bytearray); 
+2
source

Source: https://habr.com/ru/post/1488034/


All Articles