You are on page 1of 2

.

NET Notes

C# 2.0 – EXAMPLE

If a class level variable, and a Main() level variable is declared with the same name,
then the program will still compile, and referring the variable will give the Main()
level variable. If you need to access the Class level variable then use the keyword
“this”. Example namespace sunny { static int j=10; ….Main() { int j= 30;
console.writeline(j); j=30;.

Value Type – stores its value directly where as Reference Type holds the pointer to
its value, same the data on the heap. Value Type stores the value on the stack,
where reference type stores the data into a place classed “managed heap”

Predefined Value Types.

Integer Sbyte, short, int, long, byte, ushort, uint, and ulong

Floating- Float, double


point

Decimal “decimal”

Boolean “bool”

Character “char”
type

Predefined Reference Types.

Object “object”

String “string”

foreach (int temp in ArrayInt) { Console.Writeline(temp);}

Integers – int [] myint = new int[32]; int[0]=32; myint.Length will give me


the # of items in the array.

Enum – public enum myEnum {

Myitem = 0;
Myitem1 = 1;

Myitem2 = 2;
}

myEnum.Myitem =0, myEnum.Myitem.ToString() = Myitem;