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

Q: How to print my name in C Sharp?

+4 votes

Hi, I have a task to print my name in C#. How can I do it? How many ways there are?

asked in C# category by user Jolie Ann

3 Answers

+1 vote

Here is how:

using System;

class PrintMyName
{
    static void Main(string[] args)
    {
        Console.WriteLine("My name is Jolie Ann");
    }
}
answered by user andrew
edited by user golearnweb
+1 vote

Here's with variable:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

class Program
{
    static void Main()
    {
        string myName = "Andrew";
        Console.WriteLine(myName);
    }
}

 

answered by user andrew
edited by user golearnweb
+1 vote

With placeholder:

using System;

class PrintName
{
    static void Main()
    {
            Console.WriteLine("{0}", myName);
    }
}
answered by user john7
edited by user golearnweb
...