//下面是整个完整代码 using System; using System.Collections.Generic; using System.Text; namespace ArrayMaxValue74 { class Program { public static int maxValue(int[] s) { int temp = s[0]; for (int i = 0; i < s.Length; i++) { if (temp<=s[i]) { temp = s[i]; } } return temp; } static void Main(string[] args) { int[] s={10,4,5,7,8,1}; Console.WriteLine("the Max Value : {0}",maxValue(s)); Console.ReadKey(); } } }
用Linq直接查询int[] s = { 1, 5, 8, 9, 3 };
int xxx = (from mm in s select mm).Max();