Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

C#: I want every letter of a word to begin in a new line

Tags:

c#

letter

line

word

using System;

class HelloCSharp
{
     static void Main()
     {
         Console.WriteLine("Hello C#");
     }
}

I want the output to be:

H
e
l
l
o 

C
#

but every letter should start on a new line

I am new I know but I keep searching and can't find the answer. Should it be something with Environment.NewLine ?

like image 504
test player Avatar asked Jul 28 '15 09:07

test player


1 Answers

Here you go:

string str = "Hello C#"
char[] arr = str.ToCharArray();

foreach (char c in arr)
{
    Console.WriteLine(c);
}
like image 170
Luthando Ntsekwa Avatar answered Oct 21 '22 06:10

Luthando Ntsekwa