c# out参数

 static void Main(string[] args)
        {
            int[] a = { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10,0,11};
            int max; 
            int min;
            int xxa=ax((a),out max, out min);

      
            Console.WriteLine("最大值{0}",max);
            Console.WriteLine("最小值{0}",min);

            Console.ReadKey();

        }
        public static int ax(int[] xx, out int max, out int min) {
            int xxa = 0;
            max = xx[0];
            min = xx[0];
            for (int i = 0; i < xx.Length; i++) {
                if (max < xx[i]) {
                    max = xx[i];
                }
                if (min > xx[i]) {
                    min = xx[i];
                }
            
            }
            return xxa;
            
        
        }

 

posted @ 2015-09-07 22:12  尘梦  阅读(644)  评论(0编辑  收藏  举报