Sunday, 9 November 2014

Language Fundamentals in c#.net

Language Fundamentals in c#.net

The programming language C# derives from C and C++; however apart from being entirely object oriented it is type safe and simple too. Many C# statements including expressions and operators have been taken directly taken from your favourite language An important point about C# is that it simplifies and modernizes C++ in the areas of classes, namespaces and exception handling. Much of complex features have not been included or in fact hidden in C# to make it easer to use.



using System;

class He llo {
public static void Main(String[] args)
{
Console.WriteLine("Hello World");
}
}


Constants and Variables

A variable is a named memory location. They are programming elements that can change during program execution. Data that needs to be stored in memory & accessed at a later time are stored in variables. Instead of referring to the memory location by the actual memory address you refer to it with a variable name.

Variables are declared as follows
int a;

They can also be initialized at the time of declaration as follows:
int a = 10;

Constants are very similar to variables. The main difference is that the value contained in memory cannot be changed once the constant is declared. When you declare a constant its value is also specified and this value cannot be changed during program execution. Constants are used in situations where we need to keep the value in some memory location constant. If you use hard-coded values, and the value is changed then it has to be changed in all the locations in the code where it has been used. Instead if we are using constants, all we will need to do is to change the value of the constant. This would propagate the changes to our entire application.

No comments:

Post a Comment