Take the 2-minute tour ×

What is the difference between Arrays & Single-Dimensional Arrays in c#?

share|improve this question
This is like asking what is the difference between fruits and apples. –  R. Martinho Fernandes Nov 24 '09 at 16:27
Great analogy Martinho... –  JoshBerke Nov 24 '09 at 16:27
I think he may be asking about the difference between Array digits; and int[] digits; –  Stevo3000 Nov 24 '09 at 16:30
Stevo I think your right, makes sense and Marc has a good explanation of that –  JoshBerke Nov 24 '09 at 16:35

5 Answers 5

up vote 6 down vote accepted

Arrays such as int[] or int[,] inherit from Array as the base class. The main difference is that Array only offers non-specific access, where-as specific arrays (such as a single-dimension array, SomeType[]) offer direct (and typed) indexer support via the compiler etc. This allows for more efficient usage, especially as the JIT can optimise this in many cases (removing bounds checks, etc).

Array is useful if you need to be able to use any type of array (without any specific type or dimension) - although to be honest this is rare, and with generics in 2.0 onwards, it is more common to see generic methods like Foo<T>(T[]) or Foo<T>(IEnumerable<T>).

share|improve this answer

What exactly is your question? Please specify. For now here are the different types of Arrays in C#.

Single-dimensional arrays:

int[] numbers;

Multidimensional arrays:

string[,] names;

Array-of-arrays (jagged):

byte[][] scores;
share|improve this answer

Arrays is a general term refering to various types of arrays in C# (Single Dimension, Multi-Dimension or Jagged).

Single Dimension arrays are just one specific type of array in C#.

share|improve this answer

Arrays can be multi-dimensional or single-dimensional; single-dimensional arrays can only be single-dimensional.

If you want a meaningful answer, ask a meaningful question.

For much much more information, read this article.

You might be trying to ask what the difference between MDARRAYs and SZARRAYs is (see the above article).

SZARRAYs are zero-based, one dimensional arrays (inlcuding nested arrays, such as int[][][][]). The runtime is highly optimized to maximize performance for SZARRAYs.

All other arrays (non-zero-based arrays, which are not supported by C#, and multi-dimensional arrays) are MDARRAYs, which aren't as fast.

share|improve this answer

The same difference between rectangles and squares.

share|improve this answer
:D ........hahahaa –  Stan R. Nov 24 '09 at 16:31
this answer i can say but why are you not write answer about my question –  clouserw Nov 24 '09 at 16:46
Because your question doesn't make sense. –  SLaks Nov 24 '09 at 16:54
@clouserw: This is actually a serious answer. Every single-dimensional array is an array, but not every array is a single-dimensional array. The same is true for squares and rectangles. –  Dan Tao Nov 24 '09 at 18:19

Your Answer

