如何在 C# 中使用数组类的 GetLowerBound 方法
csharpprogrammingserver side programming更新于 2025/7/10 15:07:17
C# 中数组类的 GetLowerBound() 方法用于获取数组中指定维度的下限。
首先,设置数组并获取下限,如下所示 −
arr.GetLowerBound(0).ToString()
以下示例说明了 C# 中 GetLowerBound() 方法的用法。
示例
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace lower {
class Program {
static void Main(string[] args) {
Array arr = Array.CreateInstance(typeof(String), 3);
arr.SetValue("Car", 0);
arr.SetValue("Truck", 1);
arr.SetValue("Motorbike", 2);
Console.WriteLine("Lower Bound {0}",arr.GetLowerBound(0).ToString());
Console.ReadLine();
}
}
}
输出
Lower Bound 0

