How to print text diagonally from left to right in C#

1 Answer

0 votes
using System;

class Program
{
    static void printDiagonalText(string text) {
        for (int i = 0; i < text.Length; i++) {
            Console.WriteLine(new string(' ', i) + text[i]);
        }
    }

    static void Main()
    {
        string message = "HELLO WORLD";
        
        printDiagonalText(message);
    }
}


/* 
run:

H
 E
  L
   L
    O
     _
      W
       O
        R
         L
          D

*/

 



answered Apr 7 by avibootz
...