settingsAccountsettings
By using our mini forum, you acknowledge that you have read and understand our Cookie Policy and Privacy Policy
Menusettings

Q: Assign character and string values to variables in C#

+4 votes

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#

 

asked in C# category by user Jolie Ann

1 Answer

+2 votes
 
Best answer
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);
        
    }
}

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

answered by user eiorgert
edited by user golearnweb
...