C#

Learn New things from Rixosys

Introduction

What is C#(Sharp)?


C# is a programming language created by Microsoft.C# programming language is a powerful Object Oriented programming language,i.e., the entire 
C# language revolves around Objects only.
For writing C# code we have to use an Editor called Microsoft Visual Studio(can be of any version like VS 2005 or VS2008 or VS2010,etc.).

How internally C# code works?

As a programmer when we write some C# language code,the code has to be verified by C# compiler and will converted into MSIL code.
The newly produced MSIL code will be given to CLR's JIT compiler where JIT compiler will again compile MSIL code and will be conevrted into machine 
understandable instructions which will be usually in 0's and 1's.

why c# is used?

It is a general language designed for developing apps on the Microsoft platform and needs the .NET framework on Windows to figure.                  C# is usually thought of as a hybrid that takes the simplest of C and C++ to make a very progressive language.

Characteristics of c#?

Simple
Modern programing language
Object bound
Type safe
Interoperability
Scalable and Updateable
Component bound
Structured programing language
Rich Library
Fast speed

C# proramming structure

Before we tend to study basic building blocks of the C# artificial language, 
allow us to look into a blank minimum C# program structure so we will take it as a reference in forthcoming chapters.

1.Creating Hello World Program

using System;

namespace HelloWorldApplication {
   class HelloWorld {
      static void Main(string[] args) {
         /* my first program in C# */
         Console.WriteLine("Hello World");
         Console.ReadKey();
      }
   }
}

- When this code is compiled and dead, it produces the subsequent result : Hello World.
Let us look at the various parts of the given program -
1.The first line of the program using System; - the using keyword is used to include the System namespace within the program. 
A program usually has multiple using statements.
2.The next line has the namespace declaration. A namespace could be a collection of classes. The HelloWorldApplication namespace contains the class HelloWorld.
3.The next line includes a class declaration, the class HelloWorld contains the data and method definitions that your program uses. 
classes typically contain multiple methods. 
ways define the behavior of the class. However, the HelloWorld class has only 1 method Main.
4.The next line defines the main method, that is that the entry point for all C# programs. the main method states what the class does once executed.
5.The next line /*...*/ is unnoticed by the compiler and it's place to add comments within the program.
6.The Main method specifies its behavior with the statement Console.WriteLine("Hello World");
7.WriteLine could be a method of the Console class defined within the System namespace. This statement causes the message "Hello, World!" to be displayed on the screen.
8.The last line Console.ReadKey(); is for the VS.NET Users. This makes the program await a key press and it prevents the screen from running and closing quickly once the program is launched from Visual Studio .NET.