Advertisement
Qrist

Decode\Encode

Oct 28th, 2020
58
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.60 KB | None | 0 0
  1. using System;
  2. using System.Text;
  3.  
  4. public class Program
  5. {
  6.     public static void Main()
  7.     {
  8.         // String
  9.         String s = "Hi there.";
  10.  
  11.         // Encoding object
  12.         Encoding encodingUTF8 = Encoding.UTF8;
  13.  
  14.         // Encode string to byte array
  15.         Byte[] encodedBytes = encodingUTF8.GetBytes(s);
  16.         Console.WriteLine("Encoded bytes: " +
  17.                           BitConverter.ToString(encodedBytes));
  18.  
  19.         // Decode to string
  20.         String decodedString = encodingUTF8.GetString(encodedBytes);
  21.         Console.WriteLine("Decoded string: " + decodedString);
  22.     }
  23. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement