C# TUTORIAL
C# Variables
We will start this chapter wil the simple example below that takes in length and breadth of a rectangle and calculates and displays the area of the rectangle. Take a look at the following example.
using System; using System.Collections.Generic; using System.Linq; using System.Text; namespace ConsoleApplication1 { class Program { static void Main(string[] args) { int length; int breadth; int area; length = 20; breadth = 10; area = length * breadth; Console.WriteLine("Area of Rectangle is : {0}", area); Console.ReadLine(); } } } |
If you run the above program you should be able to see an output on the dos prompt type console window which shows the area of the rectangle. Take a look at the definition of the length, breadth and area variables.
int length; int breadth; int area; |
C# has a number of types that includes boolean, integral ( int, uint, long, char, uchar,sbyte, byte etc), Floating Point Types ( float, double, decimal), string type etc.
C# Operators
Take a look at the following line in the above example
length = 20; breadth = 10; area = length * breadth; |
This completes the basic tutorial of understanding the variables and operators. In the next chapter we will present a complete list of variables and operators for your reference.