如何确定C#中数组的大小
首先,设置一个数组-
int[] arr = {6, 3, 8, 4};现在,使用Length属性获取数组的大小-
arr.Length
让我们看完整的代码-
示例
using System;
namespace Demo {
public class Demo {
public static void Main(string[] args) {
int[] arr = {6, 3, 8, 4};
Console.WriteLine("Array...");
foreach (int i in arr) {
Console.Write(i + " ");
}
Console.WriteLine("\nSize of Array: "+arr.Length);
}
}
}输出结果
Array... 6 3 8 4 Size of Array: 4
热门推荐
10 读书祝福语女生短句简短
11 感谢同事新婚祝福语简短
12 感谢教官文案祝福语简短
13 员工聚会蛋糕祝福语简短
14 元宵发客户祝福语简短
15 给团队信心祝福语简短
16 医美的祝福语大全简短
17 异国姻缘的祝福语简短
18 兄妹拍照祝福语简短的话