Saturday, July 21, 2007

C# Variable Types

Here is a list of C# variable types together with a short description of each.

1. Static Variables
- variables that remains active throughout the entire life of the application
- can be declared using static keyword
- value can be changed at runtime

2. Constant Variables

- a variable whose value cannot be changed at runtime
- can be declared using const keyword

3. Instance Variables
- the ordinary variables declared in an application without any modifiers such as const, static, ref, etc.

4. Parameters given by reference
- almost similar to a pointer parameter input in C
- the changes made in this variable inside the function will also reflect in its calling function (or the main function)
- in C#, this is indicated by the ref keyword
- an out keyword may also be used to signify that the value must be returned

5. Parameters given by value
- the ordinary input parameter in a function
- a value is being passed as a parameter to the function
- whatever changes to the variable made by the function will not affect is value at the calling function (or at the main function)

No comments: