What is the difference between Arrays & Single-Dimensional Arrays in c#?
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;
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#.
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 MDARRAY
s and SZARRAY
s is (see the above article).
SZARRAY
s are zero-based, one dimensional arrays (inlcuding nested arrays, such as int[][][][]
). The runtime is highly optimized to maximize performance for SZARRAY
s.
All other arrays (non-zero-based arrays, which are not supported by C#, and multi-dimensional arrays) are MDARRAY
s, which aren't as fast.
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>)
.