Friday, October 9, 2020

C# Programming Introduction

C# is a programming language like Java, C/C++. It is developed by Microsoft and it runs on .NET Framework or .Net Core Framework.

.Net Framework runs only on windows OS but .Net Core is a cross platform framework it can runs on Linux, macOS, windows.

With C# we can develop web applications, desktop applications, mobile applications, games and much more.

C# is an object oriented programming language.

Tool we need to develop C# programming application are visual studio or visual studio code.

In this tutorial series we will use visual studio community edition which is free to download.

C# inherits its basic syntax from C/C++ if you know these two languages you feel home.

Special Notes

C# is a case sensitive language. Incorrect case prevent program from Compiling successfully.

C# application consists of the following parts

  • Declaration of Namespace
  • Class
  • Methods of Class
  • Attributes of Class
  • Main method declaration (starting point of every console application)
  • Statements 
  • Expressions
  • Comments 

Structure of C# Program

Following is a code written in C# programming language

using System;
 namespace HelloWorld
 {
  class Program 
{
  static void Main(string[ ] args) 
{
  Console.WriteLine("Hello World!"); 
                                   /*This is a comment in C# */
}
  }
 }

Explanation Of the above Code


using System;

using keyword is used to import existing classes, so we can use classes in our program define in System namespace.

;

semicolon after the end of every statement is a must in C#,  basically semicolon is a statement terminator.

namespace HelloWorld

namespace is a container for classes and files and "HelloWorld" is the name of namespace in our code.

 {    this curly brace marks the beginning of our namespace.

class Program 

this above instruction declares our class and the name of the class is Program. When we create our console application in .Net framework the " Program.cs " file is  automatically created by the framework which has a class name Program.

 this curly brace right after the declaration of our class marks the beginning of  class code.

static void Main(string[ ] args) 

Every console application has at least one Main( ) method and it is the entry point or starting point of our application, code inside this Main( ) method will be executed.

 this curly brace right after the declaration of our Main( ) method marks the beginning of our Main( ) method.

Console.WriteLine("Hello World!"); 

This Console.WriteLine(  function which is define in System namespace print the " Hello World! " on the Console.

 /*This is a comment in C# */

This above line is a multiple line comment in C# and will be ignored by the C# compiler.


}
  }
 }

These above three curly braces marks the closing of each curly brace which we had open previously in our above code.

When This above code executed it display the following output on the console.

Output

Hello World!


Here is a YouTube video Link of my Introduction To C# Programming tutorial (Urdu/Hindi language)




Written By

Syed Sohail Ahmed Quadri

YouTube Channel   Right Way Learning




Introduction To Full Stack Dot Net Development

  WHAT IS MEAN BY FULL STACK DEVELOPER A software engineer who works both on the Front End like (Angular, HTML, JavaScript, CSS, Bootstrap,...