
- 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
Get bounds of a C# three-dimensional array
To get the bounds of a three-dimensional array, use the GetUpperBound() GetLowerBound() methods in C#.
The parameter to be set under these methods is the dimensions i.e.
Let’s say our array is −
int[,,] arr = new int[3,4,5];
For a three-dimensional arrays, dimension 0.
arr.GetUpperBound(0) arr.GetLowerBound(0)
For a three-dimensional arrays, dimension 1.
arr.GetUpperBound(1) arr.GetLowerBound(1)
For a three-dimensional arrays, dimension 2.
arr.GetUpperBound(2) arr.GetLowerBound(2)
Let us see the entire example.
Example
using System; class Program { static void Main() { int[,,] arr = new int[3,4,5]; Console.WriteLine("Dimension 0 Upper Bound: {0}",arr.GetUpperBound(0).ToString()); Console.WriteLine("Dimension 0 Lower Bound: {0}",arr.GetLowerBound(0).ToString()); Console.WriteLine("Dimension 1 Upper Bound: {0}",arr.GetUpperBound(1).ToString()); Console.WriteLine("Dimension 1 Lower Bound: {0}",arr.GetLowerBound(1).ToString()); Console.WriteLine("Dimension 2 Upper Bound: {0}",arr.GetUpperBound(2).ToString()); Console.WriteLine("Dimension 2 Lower Bound: {0}",arr.GetLowerBound(2).ToString()); } }
Output
Dimension 0 Upper Bound: 2 Dimension 0 Lower Bound: 0 Dimension 1 Upper Bound: 3 Dimension 1 Lower Bound: 0 Dimension 2 Upper Bound: 4 Dimension 2 Lower Bound: 0
- Related Articles
- Get rank of a three-dimensional array in C#
- Get Upperbound and Lowerbound of a three-dimensional array in C#
- Get the width and height of a three-dimensional array
- Size of a Three-dimensional array in C#
- Accessing array out of bounds in C/C++
- Get the Inner product of a One-Dimensional and a Two-Dimensional array in Python
- Get the inverse of a Four-Dimensional array in Python
- Return a new Three-Dimensional array without initializing entries in Numpy
- Dimensional Array in C#?
- How to find the mean of three-dimensional array in R?
- What is out of bounds index in an array - C language?
- 4 Dimensional Array in C/C++
- Passing two dimensional array to a C++ function
- Why accessing an array out of bounds does not give any error in C++?
- How to declare a two-dimensional array in C#

Advertisements