Sunday, 2025-01-12, 4:46 AM
Welcome Guest | RSS
Site menu
Tag Board
500
Our poll
Which .Net class is more interset for you ?
Total of answers: 225
Statistics

Total online: 1
Guests: 1
Users: 0

16-12-2010

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] +" ");
            }
         Console.WriteLine();
        }
      Console.ReadLine();
    }
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);
      Console.ReadLine();
    }
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







Search

Time
 

 

Calendar
 
«  January 2025  »
SuMoTuWeThFrSa
   1234
567891011
12131415161718
19202122232425
262728293031

Twitter
 

Entries archive

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