Introduction to C# ( C Sharp )

Today, I am going to share a new tutorial Introduction to C#. I have recently started a series of tutorials ...

Introduction to c sharp, c# basics, basics of c#, introduction to c sharp, basics c sharpHello friends, I hope you all are fine and having fun. Today, I am going to start a new series on C# Programming Language and today we are gonna have a look at first tutorial Introduction to C#.

C# is the most widely used programming language for designing software & websites. Most of the software, we use in our daily life are designed using this C# Language. So, let's get started with detailed Introduction to C#.

Introduction to C#

  • C# (pronounced see sharp) is a general-purpose programming language developed by Microsoft in 2000, as part of .NET framework.
  • Microsoft Visual Studio is a Programming environment used for writing C#.
  • C# was originally designed by Anders Hejlsberg, who currently works as lead architect of C#.
  • I am gonna use Microsoft Visual Studio 2019 Community Edition, which is free to use, and you can download it from its official website.
  • Introduction to C#, c# basics, welcome to C#, learning c#, basics of c#There are different languages available in Visual Studio i.e. C, C++, C# and F#. C# is the most commonly used programming language among all.
  • Now, I assume that you have installed the Visual Studio and is ready to design your first project.
  • So, open your Microsoft Visual Studio, and create a New Project by clicking File and then New Project, as shown in figure on the right.
  • You can also create a new project by clicking Ctrl+N.
  • Now once you create the New Project, a new pop up window will open up, as shown in below figure:
Introduction to C#, c# basics, welcome to C#, learning c#, basics of c#
  • Now, as shown in above figure, first of all select the Visual C# as obviously we are gonna use the C# language in introduction to C#.
  • Next, select the Windows and then Console Application.
  • Next, we need to give a name to this Console Application, which I have given is MyFirstProject and finally click the OK button.
  • Now in this window, we are gonna update our code in C#. Currently, it has simple Hello World code, as shown in below figure:
Introduction to c sharp, c# basics, basics of c#, introduction to c sharp, basics c sharp
  • Let's understand this code, line by line:

Namespace Declaration

  • Introduction to c sharp, c# basics, basics of c#, introduction to c sharp, basics c sharpThe first line of code is "using System", here System is a built-in C# Namespace and we are declaring it at the top of our code.
  • Currently, we are using just 1 namespace but later on we are gonna add a lot more and all these namespace declarations will come at the top of our code.
  • You can think of namespace as a library which has different classes & methods in it.
  • So, when we declare it at the top, then all its classes become available to use in our code i.e. Console is a class of System namespace.

Projects Namespace

  • Introduction to c sharp, c# basics, basics of c#, introduction to c sharp, basics c sharpNext, we have namespace TEPProject, which is the namespace of our newly created project, all of our classes will be placed inside this namespace.
  • You can see this namespace has curly brackets { }, which has all the remaining code in them.

Program class

  • Introduction to c sharp, c# basics, basics of c#, introduction to c sharp, basics c sharp introduction to c#When you run your code, the compiler finds the projects namespace and inside this namespace, it makes a search for a C# Class named Program and in Program class, it goes into the C# Method named Main.
  • That's why, we have the class Program inside our namespace TEPProject and inside this class, we have our static void Main(string[] args) function.
  • This Main function is a static function and it has arguments with datatype string.
  • This Main Function is the entry point of our compiler in our project, we have to write our code in this function or method. ( Functions are also called methods )
  • Inside this Main function, we have simply printed Hello World to our Console.
  • This Console is a member of namespace Systems, if we remove namespace from top then this Console will create error.
So, now let's run our code and if everything goes fine then you will get something as shown in below figure:Introduction to c sharp, c# basics, basics of c#, introduction to c sharp, basics c sharp
  • We have Hello World printed in our console panel, it's doing nothing else.
  • Moreover, if you are not getting things like C# Namespace or C# Methods etc. then no need to worry, we will cover all of them in coming tutorials in detail.
  • That's all for today. In our next tutorial, we will add some code in it and will check the output.
So, that's all about Introduction to C#, I hope you guys have learned something out of it. In the next tutorial, we will design our First Code in C#. Till then take care and have fun !!! :)

Leave a Reply

Leave a Reply


Comments on ‘’Introduction to C# ( C Sharp )‘’ ( 1 )

  1. Thank You Mr. Nasir, just trying to pick up on C# as a hobby. Use Windows 7 & don’t plan to upgrade (i think ) so this is a lot of fun to my old brain. Thanks 4 your time.