Array Expressions
Besides being an efficient storage construct, arrays have additional functionality that helps make programs more expressive and powerful. The following example shows one such capability:
string[] weekDays = new string[7]; Console.WriteLine("Number of Days: {0}", weekDays.Length); // Number of Days: 7
For C++ ProgrammersFrom the perspective of traditional built-into-the-language arrays, C++ arrays are simply a pointer to a block of memory. This refers to the C++ arrays derived from its C language ancestry. C# arrays have much more functionality. The C++ STL array class is similar to the C# ArrayList collection class. Both are library classes. |
The previous example showed the array's Length property. The array type has many ...
Get C# Unleashed now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.