kyamaliev

Binary and Text

Apr 14th, 2022
1,046
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.61 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3.  
  4. namespace _03.PrimitiveDataTypes
  5. {
  6.     class DataTypesTwo
  7.     {
  8.         static void Main(string[] args)
  9.         {
  10.  
  11.             string myString = "Test String";
  12.             var myList = new List<string>();
  13.  
  14.             foreach (var ch in myString)
  15.             {
  16.                 int currentChar = (int)ch;
  17.                 myList.Add(Convert.ToString(currentChar, 2));
  18.             }
  19.  
  20.             string resultString = String.Join('|', myList);
  21.  
  22.             Console.WriteLine(resultString);
  23.             Console.ReadLine();
  24.         }
  25.  
  26.        
  27.     }
  28. }
  29.  
Advertisement
Add Comment
Please, Sign In to add comment