Thursday, November 26, 2015

Part 2 - Reading and writing to a console

In this lession, we will discuss
          1. Reading from the console
          2. Writing to the console
          3. Two ways to write to console
                     a) Concatenation
                     b) Place holder syntax – Most preferred

using System;
class Program
{
    static void Main()
    {
        // Prompt the user for his name
        Console.WriteLine("Please enter your name");
        // Read the name from console
        string UserName = Console.ReadLine();
        // Concatenate name with hello word and print
        Console.WriteLine("Hello " + UserName);

        //Placeholder syntax to print name with hello word 
        //Console.WriteLine("Hello {0}", UserName);
    }
}
Note: C# is case sensitive language.

No comments:

Post a Comment