Jump to content

Language Specification 4.0

- - - - -

  • Please log in to reply
2 replies to this topic

#1
Tonchi

Tonchi

    Programming Expert

  • Members
  • PipPipPipPipPipPip
  • 471 posts
  • Location:Varaždin
  • Programming Language:C, C++, C#
This is quote from specification:

Quote

For example, int[] is a single-dimensional array of int, int[,] is a two-dimensional array of int, and int[][] is a single-dimensional array of single-dimensional arrays of int.
i don't understand the bold one...in C language int[][] is two-dimensional array but here is not...can somebody help me to understand this???

#2
WingedPanther

WingedPanther

    A spammer's worst nightmare

  • Moderators
  • 16,831 posts
  • Location:Upstate, South Carolina
  • Programming Language:C, C++, PL/SQL, Delphi/Object Pascal, Pascal, Transact-SQL, Others
  • Learning:Java, C#, PHP, JavaScript, Lisp, Fortran, Haskell, Others
Here's the key:

int[] myArray declares a reference to a one dimensional array. You will have to use the new operator to create an actual array.
int[,] myArray declares a reference to a two dimensional array. You will have to use the new operator to create an actual array, and it will be rectangular.
int[][] myArray declares a reference to a one dimensional array of references to one dimensional arrays of ints. You will need to use a new operator to create an actual array of references, and run through a loop to create the sub arrays. The result may or may not be rectangular.
Programming is a branch of mathematics.
My CodeCall Blog | My Personal Blog

#3
Momerath

Momerath

    Programming Professional

  • Members
  • PipPipPipPipPip
  • 242 posts
int[][] myArray - This is known as a jagged array, as the number of columns in each row don't have to be the same.




1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users