0

Are arrays in C# always objects?

My background is in other languages where arrays are created and accessed by index ( array[0] ) without being treated as objects, and I could swear I've seen this done in c++ or c# somewhere. in particular, the int[] array = new int[5]; rather than int array[5]; is throwing my brain for a loop. So... are arrays always objects in c# or is there a 'simple' context as well?

6th Jul 2016, 6:49 PM
David Ramsey
David Ramsey - avatar
2 Answers
+ 1
They are objects, and they are pasted by reference, almost everything in c# is a object because is an OO language.
7th Jul 2016, 1:22 PM
Elfren Authorlee
Elfren Authorlee - avatar
0
There are reference types and value types in c#. Arrays are reference types. Any subclass of object is a reference type.
7th Jul 2016, 8:52 PM
Ivan G
Ivan G - avatar