C# is know as a C-Sharp, is a programming language introduced by Microsoft. C# contains features similar to java and C++, It is specially designed to work with Microsfot.Net platform.
All language have a vocabulary, Which is a list of words have a specific meaning in that language. Language also have their own grammar rules
Computers can’t understand these languages directly.
For example if you have recipe book in Spanish language you have to translate that book in English or your native language. Similar way we need a complier to convert any programming language in machine language.
A compiler is a special program that processes the statements written in a particular programming language and converts them into machine language. The compiler also follows the Input-Process-Output cycle. It takes the programming language instructions as input, process these instructions into machine language and these instructions executed by the computer.
For each programming language there is different compiler available, For C language there is C Compiler, For Java java compiler, For C# you will use csc (C# compiler).
The first line of code that a C# compiler looks for in the source file compiled is the Main function.
Main() Function is the entry point of the application
The Main() function is ideally used to create objects and invoke member functions
Console is a class that belongs to the System namespace. System is a namespace. Namespace is a collection of classes. Writeline() is method. the console class ha other methods which are used for various input/output operations.
Functions is a set of statements that performs a specific task in response to a message. The functions of a class are member functions. Member functions declared in the class.
The preceding line can also be written as Console.WriteLine()
Variable is a location in the memory that has a name and contains a value. The value could be integer, decimal, or character. A variable is associated with a data type that defines the type of data which can be stored in a variable.
For Example A variable called student name will ideally store characters, whereas a variable called steudent_marks will store numbers.
Following are examples of valid variables:
Following are examples of valid variables
Note: C# is case sensitive language. This means that the variable StudentName is not same as student name.
Data types in C#:
- Char (Characters)
- Int (numbers)
- Float (Small decimal values)
- bool (True or false)
- double (decimal values)
- string (0-2 million Unicode characters)
- int marks;
- char name;
Types of data types:
Value Type: They directly contains data.
Reference Type: The reference types do not maintain data but they contain a reference to the variables, which are stored in the memory.
Accepting and storing values in Member variables:
- int number;
- number = Convert.ToInt32 (Console.ReadLine);