find and solve ||
Please wait.....

Learn C# Programming step by step

C# Tutorial

This is c# coding tutorial for beginners which is developed by Microsoft and runs on .NET Framework. It is used to develop web apps, mobile apps, desktop apps, games, and much more things.

C# programming tutorial for beginners - Introduction

It is usually pronounced “C-Sharp”. It is an object-oriented programming language. This programming language is closer to other popular languages like Java and C++ and has roots in the C family. Its first version was released in the year 2002. As of 2021, the latest version, C#9.0, was released in 2020 in .NET 5.0.

C# is used for Mobile applications, Desktop applications, Web applications, Web services, Web sites, games, VR, Database applications.

Why Use C#?

  •  It is One of the most popular programming languages in the world
  •  Very convenient to learn and simple to use
  • Got a huge community support
  •  Since it is an object-oriented programming language, it gives a clear structure to programs and allows code to be reused, and this lowers development costs.
  • As C# is close to C, C++, and Java, it makes it easy for programmers to switch to C# or vice versa

C# Syntax

 We create a C# file called Program.cs, and we use the following code to print "Hello World" to the screen:

using System;
namespace HelloWorld
     class Program
           static void Main(string[] args)
              Console.WriteLine(“Hello World!”);

Hello World!

C# Beginner Course  Example Explained

  • Line 1: using System means that we can use classes from the System namespace.
  • Line 2: It is a blank line as C# ignores white space. However, multiple lines make the code more readable.
  • Line 3: namespace is used to organize code as well as it is a container for classes and other namespaces.
  • Line 4: Curly braces {} marks the beginning and end of a block of code.
  • Line 5: Class is a container for data and methods, which brings functionality to our program. Every line of code that runs in C# must be inside a class. In our example, we named the class Program.
  • Line 7: The next thing that always appears in the C# program is the Main method. Any code inside its curly brackets{} will be executed. There is not any need to understand the keywords before and after Main.
  • Line 9: Console is a class of System namespace, which has a WriteLine() method that is used to output/print text. In our example, our output will be “Hello World!”. If we omit the using System line, we would have to write System.Console.WriteLine() to print/output text.

 Note: Every C# statement ends with a semicolon.

Note: C# is case-sensitive: "MyClass" and "myclass" has a different meaning. Unlike Java, the name of the C# file does not have to match the class name, but they often do (for better organization). When saving the file, save it using a proper name and add ".cs" to the end of the filename.