
- 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 does Array.Rank property of array class do in C#?
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[5,5];
If you want to get the rows and columns the array has, then use 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[4,5]; Console.WriteLine(arr.GetLength(0)); Console.WriteLine(arr.GetLength(1)); 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
4 5 Upper Bound: 3 Lower Bound: 0 Dimensions of Array : 2
- Related Articles
- What does Array.IsFixedSize property of array class do in C# ?
- What does Array.IsReadOnly property of array class do in C#?
- What does Array.Length property of array class do in C#?
- What does Array.LongLength property of array class do in C#?
- What does Array.IsSynchronized property of array class do in C#?
- What does Array.SyncRoot property of array class do in C#?
- What does a semicolon do after a C++ class name?
- What does built-in class attribute __dict__ do in Python?
- What does built-in class attribute __doc__ do in Python?
- What does built-in class attribute __module__ do in Python?
- What does built-in class attribute __bases__ do in Python?
- What is the Count property of ArrayList class in C#?
- What is the Capacity property of SortedList class in C#?
- What is the Count property of BitArray class in C#?
- What is the Count property of Hashtable class in C#?

Advertisements