Basic -C# Reading and writing to a console




     * Reading From the Console
     * Writing to the Console
     * Two Ways To Write Console
           1)  Concatenation 
           2)  Place Holder Syntax


Reading and Writing to Console 


using System; // A Namespace is used to Organize your code and is Collection of Classes
    class Program
    {

        static void Main()  // Main Methods 
        {
            // Prompt The User For His First Name 
            Console.WriteLine("Enter First Name");
            // Read the name from Console 
            string firstname = Console.ReadLine();
            // Prompt the User For His Last Name
            Console.WriteLine("Enter Last Name");
            // Read the Last name from Console 
            string Lastname = Console.ReadLine();
            // Concatenate 
            // Concatenate name with hello word and Print 
            Console.WriteLine("Hello " + firstname + Lastname);
            // Placeholder syntex to Print Name 
            Console.WriteLine("Hello  {0}", firstname);
            Console.WriteLine("Hello  {0}", Lastname);
            Console.Read();
        }
    }   


Namespace:  A Namespace is used to Organize your code and is Collection of Classes
    Example :  Interface , Structs . Enums and Delegates.

Concatenate Definition :  Concatenation is a process of appending one string to the end of another string.When you concatenate string literals or string constants by using the + operator.


Concatenate :   Console.WriteLine("Hello" + firstname );

Placeholder Syntax :  Console.WriteLine("Hello {0}", firstname )

Comments

Popular posts from this blog

CREATING INTERNET APPLICATION PROJECT & MVC USING DATA BASE FIRST APPROACH

Real Time Example add dynamic fields using jquery looking Treeview

Nullable Type In C# with Example

How to create DATA BASE And Tables in MSSQL Server

Data Type Conversions in C# with real time example