Introduction to C#

This is a quick tutorial for getting introduced to the C# environment. Both beginners and professionals who want to learn or revisit the concepts can take full advantage of this series. To utilize this series

This is a quick tutorial for getting introduced to the C# environment. Both beginners and professionals who want to learn or revisit the concepts can take full advantage of this series. To utilize this series please try to practice the examples simultaneously in a code editor.

Hello World:

using System;

namespace C_sharp_fundamental
{
    class Program
    {
        static void Main(string[] args)
        {
            Console.WriteLine("HelloWorld");
            Console.ReadKey();
        }
    }
}

Congratulations you have written your first C# program. Next, let’s look at the various parts of the C# program.

Parts Of C# Program:

  1. Including Namespaces: To include a namespace we use USING followed by namespace. Namespaces are containers which contain classes and functions in them. You can think of them as libraries in C.
  2. Declaring Namespaces: To declare your own namespace we use namespace followed by Variable Name. ex: namespace C_sharp_fundamental
  3. Classes: They are user-defined data types that represent the state and behavior of an object.
  4. Class Declaration: To declare a class we use the “CLASS” keyword followed by a class name.
  5. Main Method: It is the entry point of the program so only one main will be defined.
  6. Statements and Expressions: They define what the program must do and how it is done.
  7. Comments: We can add comments to the program for an understanding of the code blocks.

Leave a Reply

Your email address will not be published. Required fields are marked *