GetUpperBound()在C#数组类的方法得到的上界在数组中指定的尺寸。
首先,设置数组并获得上限,如下所示:
arr.GetUpperBound(0).ToString()
以下是说明GetUpperBound()C#中方法用法的示例。
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();
      }
   }
}输出结果
Upper Bound: 5