Thursday, 2017-06-22, 9:54 PM
Welcome Guest | RSS
Site menu
Tag Board
Our poll
How is .Net classes by R.N.Reddy sir ?
Total of answers: 234

Total online: 1
Guests: 1
Users: 0


3. Jagged Array: Jagged array is a collection of rows which may contain distinct number of elements in each row i.e., if the 1st row is having two elements, 2nd row may have three elements or it may depend upon our requirement.

Jagged array is a collection of 1-dimensional arrays.

By using jagged array we can save the memory.

Syntax: <Data type> [] [] <array name> = new <data type> [size][];

Eg: for jagged array:

    Void main()
      int [][] jagged = new int [3][];
      jagged[0] = new int [] {1, 2};

      jagged[1] = new int [] {3, 4, 5};

      jagged[2] = new int [] {6, 7, 8, 9};

      for(int i=0; i < jagged.Length; i++)
         for(int j=0; i < jagged[i].Length; j++)
              Consle.Write(jagged[i][j] +" ");
Output: 1 2
              3 4 5
              6 7 8 9

Length Property: When we are working with one dimensional array length property will determine number of elements.

When we are working with jagged array length property will represent number of rows of jagged array.

Type Casting (or) Type Conversion: Converting from one data type to another data type is called as Type casting.

Whenever we want to convert from one data type value into some other data type variable we will go for type casting technique.

C#.Net will support Type casting in 3 ways:
    1. Implicit type casting
    2. Explicit type casting
    3. Boxing & Unboxing type casting

1. Implicit type casting: Implicit type casting is not controlling by the program, which is controlling by the compiler.

To implement implicit type casting, Programmer need not to follow any special syntax, except assignment operator(=).

Whenever we want to convert form small size data type value to bigger size data type value we go for it.

Eg: For implicit type casting:
    Void main()
      Short SNumber = 25;
      int iNumber  = SNumber;
      Console.WriteLine("iNumber value is " +iNumber);
Output: iNumber is 25.

2. Explicit Type Casting: Explicit type Casting is controlling by the programmer.

To implement explicit type casting a programmer has to follow some special syntax.

Whenever we want to convert from bigger size data type to smaller size data type, we go for explicit type casting.

Explicit type casting we can implement by using three techniques.
    1. C++ style of type casting.
    2. Parsing
    3. Converting




«  June 2017  »


Entries archive

Copyright R N Reddy © 2017Developed by Nagendra, Venkat, Vijaya and Yaswanth
Get free updates as SMS to your mobile. Just register by clicking here