[Solved] Assign character and string values to variables in C#

  

1
Topic starter

I need to create a program in C# that assigns character and string values to variables. They must be in char and string.

The output must look like this:

H

e

l

l

o

I love C#

1 Answer
1

Be careful with using the " " (double quotes for string) and ' ' (single quotes for char)!

using System;
 
class CharactersStrings
{
    static void Main()
    {
        char a = 'H';
        char b = 'e';
        char c = 'l';
        char d = 'l';
        char e = 'o';
        string f = "I love C#";
 
        Console.WriteLine("{0}\n{1}\n{2}\n{3}\n{4}\n\n{5}\n", a, b, c, d, e, f);
         
    }
}
Share: