Introduction of C#

C# is pronounced as CSharp and it was developed by Microsoft , it is an Object Oriented Programming Language that enables you to develop Secure, Reliable and Robust applications on the Microsoft .Net platform.

C# is Simple, Type Safe language that involves less coding with rich Graphical User Interface.

You can build Windows Applications , Console Applications , Distributed Components , Client Server Web Applications and Database Applications with the help of C#.

C# supports Garbage Collection at runtime that automatically manage the Memory and freed the unused objects , it supports the concept of Properties , Enumerations and Preprocessor directives.

C# combines the Power and Efficiency of C++, Simplicity and Object Oriented approach of Java and Creativeness of VB.

Why should you learn C# ?

C# is easy to learn and its syntax as like other high level programming languages.

C# has a large Developer Community support and easily integrate with Microsoft technologies.

It has large set of inbuild Libraries that supports the fast developement with accuracy of code.

It has improved performace due to strong support of Type Casting and Automatic Memory Management.

It supports the Game Development and it is used in Artificial Inteligency.

It has Cross Platform support so that you can develop applications for Linux,Windows and Mac Os.

C# Program Structure

                
 using System;
 namespace ProgramStructure
 {
     internal class Program
     {
         static void Main(string[] args)
         {
             Console.WriteLine("This is first program in c#");
         }
     }
 }

Program Explaination

In the above Program first line is "using Sytem" , here using is a Keyword used for including any namespace in the Program and System is the namespace which is used in the program.
Do not worry about the namespace on this point we will discussed it later in upcoming tutorials but you need to know about the namespace in some basic way.
Namespace is the collection of Predefined Classes and their Refernce Types and Value Types.
System is the namespace used for adding the Base Classes into the Program.

Namespace ProgramStructure is the name of the project in which we are going to add our classes , interfaces , events and all the things related to program.

internal is the by default access specifier for Program class when we create a project . Program is the name of Class from where we can run our application and it uses a Entry Point called Main() method that is executed first in any console application.

C# Console Read and Write :- When you want to Read some inputs from the Console or You want to Write some output to Console window then you have to use Console.ReadLine() for Read the data inputs and Console.WriteLine() for Write output on Console.

Example :- For a School Managment System operator wants to search any Student then he/she has to write the Name of Student on Console and then press Enter then program will show details of the Student on the console output so in this Scenario we have to use Console Class ReadLine() and WriteLine() Methods as shown in given example program.

                
 using System;
 class Student 
 { 
    static void Main() 
      { 
             // Enter the Name for Student to get Details
              Console.WriteLine("Please Enter Student Name");
             // Read the name from console and save it into the String Variable StudentName
             string StudentName = Console.ReadLine();

             //Display Student Name on Screen
             Console.WriteLine("You Enter Your Name as : " + StudentName);
             // Concatenate Student Name with Welcome Message and Display it on Screen
             Console.WriteLine("Welcome Mr. :" + StudentName);

             //Placeholder syntax to print Student with Welcome Message
             Console.WriteLine("Welcome  :{0}", StudentName);
      }
 }  

Output of Above Program :

Please Enter Student Name :- Sudhir Singh Chouhan
You Enter Your Name as :- Sudhir Singh Chouhan
Welcome Mr. :- Sudhir Singh Chouhan
Welcome :- Sudhir Singh Chouhan

Explanation of Above Program :   In the above program we use Using System in the first line of the Program so what does it means?

System is a NameSpace which include defination for Console class and provides all the functionality for the Console Classes and their methods into the Program.
Main() is the Entry point of the program , execution of program starts from here so it is neccessarry to write Main() Method into the Program.

Console.WriteLine() is used for write some output on the Output Screen or Console just like here , Console.WriteLine("Please Enter Student Name") it will display "Please Eneter Student Name" on the Screen.

Console.ReadLine() is used for Read some input data from the Output Screen or Console or enter the data from the keyboard just like here , string StudentName = Console.ReadLine() it will save whatever values enter from the keyboard into the StudentName variable.

Console.WriteLine("Welcome Mr. :" + StudentName) is used for display StudentName variable's value with the Concatenatation of "Welcome Mr." so here "+"Sign is used for Concatenate two strings and display it on Screen. We can also use PlaceHolder Syntax for the Concatenate the string just like Console.WriteLine("Welcome :{0}", StudentName) Here {0} is used as a placeholder and it will concatenate the strings.

Home Next

Image is not available

About the Author
Sudheer Singh Chouhan is a Software Engineer having Expertise in Development Design and Architecting the applications , Project Management , Designing Large Scale Databases in SQL Server since last 17 Years.
Skill Sets :- Microsoft .NET technologies like ASP.Net Core, Web API, LINQ, Web Forms, WinForms, SQL Server, EntityFramework, Design Patterns, Solid Principles, Microservices, AWS Cloud.