Professional Documents
Culture Documents
LIFE TIME
Mr. G.C.Deshpande
Lecturer, CSE@KLS.GIT
all languages
Human readable description of errors
Core members of
System.Exception type
Core members of
System.Exception type
Catching Exceptions
Catching Exceptions
Catching Exceptions
Role of Encapsulation
Role of Polymorphism
Role of Polymorphism
C# Access Modifiers
C# Access Modifiers
Traditional Encapsulation
Traditional Encapsulation
Chaining of Constructors
Chaining of Constructors
Inheritance
Inheritance
Arrays in C#
An array is a set of data items, accessed using a numerical index
An array is a set of contiguous data points of the same type
Arrays in C#
Array of objects
Multidimensional Arrays
[ Rectangular ]
Declaration
int[,] myArray = new int[4,2];
int[,,] myArray = new int [4,2,3];
Initialization
int[,] myArray = new int[,] {{1,2}, {3,4}, {5,6},
{7,8}};
int[,] myArray = {{1,2}, {3,4}, {5,6}, {7,8}};
int[,] myArray;
myArray = new int[,] {{1,2}, {3,4}, {5,6},
{7,8}};
// OK
myArray = {{1,2}, {3,4}, {5,6}, {7,8}};
// Error
Multidimensional Arrays
[ Rectangular ]
sizes.
A jagged array is sometimes called an "array-of-arrays.
Declaration
int[][] myJaggedArray = new int[3][];
Initialization
myJaggedArray[0] = new int[5];
myJaggedArray[1] = new int[4];
myJaggedArray[2] = new int[2];
myJaggedArray[0] = new int[] {1,3,5,7,9};
myJaggedArray[1] = new int[] {0,2,4,6};
myJaggedArray[2] = new int[] {11,22};
};
int[][] myJaggedArray = {
new int[] {1,3,5,7,9},
new int[] {0,2,4,6},
new int[] {11,22}
};
Boxing
Conversion from value type to reference type
int m=100;
object om=m; //creates a box to hold m
int m=100;
object om=(object)m; //c-style casting
int m=10;
object om=m;
m=20;
console.writeline(m); //m=20
console.writeline(om); //om=10
Unboxing
Conversion from reference type to value type
int m=10;
object om=m; //box m
int n=(int)om; //unbox om
int m=500;
object om=m
byte n=(byte)om; // run-time error
Remember: We can only unbox a variable that has
previously been boxed
References
1] Andrew Troelsen, Pro C#with.NET 3.0, SpecialEdition,
Dream tech Press, India, 2007.
2]E. Balagurusamy, Programming in C#, 5thReprint, Tata
McGraw Hill,
2004(For Programming Examples).
3] Tom Archer, Inside C#, WP Publishers, 2001.
4]Herbert Schildt,C#: The Complete Reference, TMH,
2004.
5] Yashavant Kanetkar, C#.NET fundas, First Edition, BPB
Publications,
2002
Contact Me
Email: gcdeshpande@git.edu
gcdeshpande@hotmail.com
Blog: gcdeshpande.spaces.live.com
Follow on twitter:
www.twitter.com/gcdeshpande