gpt4 book ai didi

c# - 查找数组的边界? C#

转载 作者:行者123 更新时间:2023-11-30 13:15:34 25 4
gpt4 key购买 nike

看到以下工作来自 C++ 背景,我有些惊讶。它显然在运行时保存了边界信息,我如何获得第一个和第二个边界?

欢迎反射(reflection),但不推荐。

    ff(new int[3, 4]);

static void ff(int[,] a)
{
var aa = a[1, 2];
}

最佳答案

int bound0 = a.GetUpperBound(0);
int bound1 = a.GetUpperBound(1);

关于c# - 查找数组的边界? C#,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6401551/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com