C#学习(第4天)

今天开始学习第6章,函数,其实都挺简单的,看来我得加快进度学习才行!

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace ConsoleApplication7
{
   
    class Program
    {
        static int MaxValue(int[] intArray)
        {
            int maxVal = intArray[0];
            for (int i = 1; i < intArray.Length; i++)
            {
                if (maxVal < intArray[i])
                    maxVal = intArray[i];
               
            }
            return maxVal;

        }

        static void Main(string[] args)
        {
            int[] myArray = { 1, 8, 3, 6, 2, 5, 9, 3, 0,50,100 };
            int maxVal = MaxValue(myArray);
            Console.WriteLine("The maximum value in myArray is {0}", maxVal);
            Console.ReadKey();
        }
    }
}

posted @ 2009-09-24 17:56  zxlxy  阅读(139)  评论(0编辑  收藏  举报