Sunday, 11 September 2016

Hello World in C#.Net

Hello World Program in C#.Net

using System;

namespace CsharpProgram
{
    class Program
    {
        static void Main(string[] args)
        {
            Console.WriteLine("Hello World!");
            Console.ReadKey();
        }
    }
}


Here Console.WriteLine() is use to display message to console screen.
Console.ReadKey(); is used to retain console screen , it will wait for user to press any key.


c# program which ask for your name and write it back with Greet.

using System;

namespace CsharpProgram
{
    class Program
    {
        static void Main(string[] args)
        {
            string Name;
            Console.WriteLine("Please enter your name!");
            Name = Console.ReadLine();

            Console.WriteLine("Hello, Your name is " + Name);
            Console.ReadKey();
        }
    }
}

Console.ReadLine() is use to read message entered by user.

No comments:

Post a Comment