Friday, November 3, 2017

Utility C# Class to Convert String and Bytes

Many times I have found myself  needing to convert bytes to strings or vice-versa. This is actually pretty easy to do in C# however is very easy to forget.  Most examples usually include default encoding to their liking. I have found many times I need a different encoding and sometimes different encoding in the same project. 

Easily solved by the following example.



The main feature of this is that a enumeration was created with the common encoding then a static variable is used to store my preferred default. If an alternative encoding is needed I just provide a optional EncodingType parameter to my preferred conversion.

Pretty useful :)

Utility C# Class to Convert String and Bytes

Many times I have found myself  needing to convert bytes to strings or vice-versa. This is actually pretty easy to do in C# however is very ...