Advertisement
VanessaShopping

Change Char Color in String

Aug 31st, 2016
269
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.92 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Threading.Tasks;
  6.  
  7. namespace BgColorConsole
  8. {
  9.     class BgColorConsole
  10.     {
  11.         static void Main(string[] args)
  12.         {
  13.             string str = Console.ReadLine();
  14.             char[] charAray = str.ToCharArray();
  15.             foreach (var item in charAray)
  16.             {
  17.                 if (item >= 1040 && item <= 1103)
  18.                 {
  19.                     ConsoleColor fontcolor = ConsoleColor.Red;
  20.                     Console.ForegroundColor = fontcolor;
  21.                     Console.Write(item);
  22.                 }
  23.                 else if (item < 1040 || item > 1103)
  24.                 {
  25.                     ConsoleColor fontcolor = ConsoleColor.Yellow;
  26.                     Console.ForegroundColor = fontcolor;
  27.                     Console.Write(item);
  28.                 }
  29.             }
  30.         }
  31.     }
  32. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement