Introduction to C#

Introduction of C#

A Program need to be written a specific language it is called programming language . So C# is one of programming language.

Compiler

It is a Program that process instruction written in a programming language and translate to machine language.

Class in C#

It is group of object having some behavior every object belong to a particular class. In a class object communicate with each other by passing messages.

Mathod in C#

Is a set of one or more program statement which can be execute by referencing to the method name.

What is Object in C#

Is a Combination of massage or data (is thing which can be easily identify).

What is Main method in C#

You must include a Main() method in a class to make program executable. This is the Entry point of your program. The execution of program always start from Main.

A Program Print Hello word in C#

using System;

class HelloPrint

{

static void Main()

{

Console.WriteLine("Hello");

}

}


Output

Hello

Variable in C#

It is storage area of Program. Variable is Location in the Memory that have a name and contain a value. There are two types of variable.

  1. Value type.
  2. Reference type.

Data Type in C#

It is the type of data (variable) store in that location data type in c#. following types of data types.

  1. Char - 2 byte store any character.
  2. Int - 4 byte store any integer value.
  3. Float - 4 byte store decimal value.
  4. Double - 8 byte store decimal value.
  5. Bool -1 bit store Boolean value.

A Program that accept a Name and Display a Welcome Message

using System;

Class WelcomMsg

{

static void Main()

{

string Name;

Console.WriteLine(Enter a Name");

Name=Console.ReadLine();

Console.WriteLine("Welcom!"+Name);

}

}


What is Using keyword in C#

The Using keyword is used to include namespaces in the program. The statement

Using System;

declare that you refer to the class define in the System name spaces.

Class Keyword

The class keyword is used to declare a class. In the preceding code, the class keyword define the print welcome Message.

ReadLine Mathod in C#

The ReadLine() method is used to accept input from user. The console.ReadLine() method, by default accept the data in the string format. If you want to store the data in any other format you need to convert the data type of the data provided by the user.