tags:

views:

386

answers:

5

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

+7  A: 

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;
Stan R.
+3  A: 

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#.

JoshBerke
+2  A: 

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.

SLaks
+6  A: 

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>).

Marc Gravell
+1  A: 

The same difference between rectangles and squares.

Dan Tao
:D ........hahahaa
Stan R.
this answer i can say but why are you not write answer about my question
Because your question doesn't make sense.
SLaks
@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