How to change the encoding of a String using C# and VB.NET

To change the encoding of a String using .NET you can use this Extension Method which is part of the Fesslersoft.Extensions. This method needs a source and a target encoding. Some people might find the source encoding parameter needless, but as Joel stated in his excellent blogpost

“It does not make sense to have a string without knowing what encoding it uses” (Joel Spolsky)

Samples

Sample C#

VB.NET Sample

If you have any questions or suggestions feel free to rate this snippet, post a comment or Contact Us via Email.

Related links:

Please Share us:
Please rate this snippet

Leave a Reply