📜  c# 数组元素之和# - C# 代码示例

📅  最后修改于: 2022-03-11 14:49:09.384000             🧑  作者: Mango

代码示例1
int[] arr = new int[] { 1, 2, 3 };
int sum = 0;
for (int i = 0; i < arr.Length; i++)
{
    sum += arr[i];
}

int[] arr = { 3, 6, 4, 1, 6, 8 };

// returns 1
Array.IndexOf(arr, 6);

int maxValue = anArray.Max();
int maxIndex = anArray.ToList().IndexOf(maxValue);