
- C# Basic Tutorial
- C# - Home
- C# - Overview
- C# - Environment
- C# - Program Structure
- C# - Basic Syntax
- C# - Data Types
- C# - Type Conversion
- C# - Variables
- C# - Constants
- C# - Operators
- C# - Decision Making
- C# - Loops
- C# - Encapsulation
- C# - Methods
- C# - Nullables
- C# - Arrays
- C# - Strings
- C# - Structure
- C# - Enums
- C# - Classes
- C# - Inheritance
- C# - Polymorphism
- C# - Operator Overloading
- C# - Interfaces
- C# - Namespaces
- C# - Preprocessor Directives
- C# - Regular Expressions
- C# - Exception Handling
- C# - File I/O
- C# Advanced Tutorial
- C# - Attributes
- C# - Reflection
- C# - Properties
- C# - Indexers
- C# - Delegates
- C# - Events
- C# - Collections
- C# - Generics
- C# - Anonymous Methods
- C# - Unsafe Codes
- C# - Multithreading
- C# Useful Resources
- C# - Questions and Answers
- C# - Quick Guide
- C# - Useful Resources
- C# - Discussion
What are the properties of array class in C#?
The Array class is the base class for all the arrays in C#. It is defined in the System namespace. The following are the properties of array class −
Here are the properties of the Array class −
Sr.No | Property & Description |
---|---|
1 | IsFixedSize Gets a value indicating whether the Array has a fixed size. |
2 | IsReadOnly Gets a value indicating whether the Array is read-only. |
3 | Length Gets a 32-bit integer that represents the total number of elements in all the dimensions of the Array. |
4 | LongLength Gets a 64-bit integer that represents the total number of elements in all the dimensions of the Array. |
5 | Rank Gets the rank (number of dimensions) of the Array. |
Let us see an example to find the number of dimensions of an array, using the Rank property.
arr.Rank
Here, arr is our array −
int[,] arr = new int[3,4];
If you want to get the rows and columns it has, then uses the GetLength property −
arr.GetLength(0); arr.GetLength(1);
The following is the complete code −
Example
using System; class Program { static void Main() { int[,] arr = new int[3,4]; Console.WriteLine(arr.GetLength(0)); Console.WriteLine(arr.GetLength(1)); // Length Console.WriteLine(arr.Length); Console.WriteLine("Upper Bound: {0}",arr.GetUpperBound(0).ToString()); Console.WriteLine("Lower Bound: {0}",arr.GetLowerBound(0).ToString()); Console.WriteLine("Dimensions of Array : " + arr.Rank); } }
Output
3 4 12 Upper Bound: 2 Lower Bound: 0 Dimensions of Array : 2
- Related Articles
- How are the methods and properties of Array class in C# useful?
- What are the methods and properties of the Thread class in C#?
- What are the properties of an array object in JavaScript?
- Properties of the Thread Class
- What are the properties of subtraction?
- What are the properties of light?
- What are the properties of Materials
- What are the properties of the triangle?
- What are some of the commonly used methods of the array class in C#?
- What are the interfaces implemented by Array class in C#?
- What are the properties of a parallelogram?
- What are the properties of window.screen object in JavaScript?
- What are the basic properties of products in TOC?
- What are the properties of Regular expressions in TOC?
- What are accessors of properties in C#?

Advertisements