32 数组在函数,属性中的传递

数组在函数中的传递

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

namespace suz
{
    class Program
    {
        static void Main(string[] args)
        {
            At ced = new At();
            int[] arr2 = new int[9] {1,2,3,4,5,6,7,8,9};
            ced.Arr(arr2);
            foreach(int name in arr2)
            {
                Console.WriteLine(name);
            }
            Console.WriteLine(ced.arr[3]);
        }
    }
    class At
    {
        public int [] arr= new int[9];
        public void Arr(int [] ArrValue)
        {
            arr=ArrValue;
        }
    }
}

数组在属性中的传递

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

namespace suz
{
    class Program
    {
        static void Main(string[] args)
        {
            At ced = new At();
            int[] arr2 = new int[9] {1,2,3,4,5,6,7,8,9};
            ced.Arr = arr2;
            foreach(int name in arr2)
            {
                Console.WriteLine(name);
            }
            Console.WriteLine(ced.arr[8]);
        }
    }
    class At
    {
        public int [] arr= new int[9];
        public int[] Arr
        {
            //get { }只读
            set//只写
            {
                arr = value;
            }
        }
    }
}

 

 

posted on 2013-05-05 20:12  杨柳清枫2012  阅读(94)  评论(0)    收藏  举报

导航