- Data Structure
- Networking
- RDBMS
- Operating System
- Java
- MS Excel
- iOS
- HTML
- CSS
- Android
- Python
- C Programming
- C++
- C#
- MongoDB
- MySQL
- Javascript
- PHP
- Physics
- Chemistry
- Biology
- Mathematics
- English
- Economics
- Psychology
- Social Studies
- Fashion Studies
- Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
How to use the GetUpperBound method of array class in C#?
The GetUpperBound() method of array class in C# gets the upper bound of the specified dimension in the Array.
Firstly, set the array and get the upperbound as shown below −
arr.GetUpperBound(0).ToString()
The following is an example stating the usage of GetUpperBound() method in C#.
Example
using System; using System.Collections.Generic; using System.Linq; using System.Text; namespace Demo { class Program { static void Main(string[] args) { Array arr = Array.CreateInstance(typeof(String), 6); arr.SetValue("One", 0); arr.SetValue("Two", 1); arr.SetValue("Three", 3); arr.SetValue("Four", 4); arr.SetValue("Five", 5); Console.WriteLine("Upper Bound: {0}",arr.GetUpperBound(0).ToString()); Console.ReadLine(); } } }
Output
Upper Bound: 5
Advertisements