C#求和

namespace ConsoleApplication3
{
    class Program
    {
        static void Main(string[] args)
        {
          //  Person2.SayHello();
            Person2 p2 = new Person2();
           int m= p2.AddParams(1, 2, 3, 4);
            //Person2.age
           Person3 p3 = new Person3();
          // p3[0] = 0;
           Console.WriteLine( p3[0] = 0);
            Console.ReadKey();
        }
    }


    class Person
    {
        private int height;
        public int Height
        {
            get { return height; }
            set { height = value; }
        }
        public int Age;
        private string name;

        public string Name
        {
            get { return name; }
            set { name = value; }
        }

        public string ReturnName()
        {
            string aa;
            aa = this.name;
            return aa;

        }


        public void GiveName(string Namm)
        {
            this.name = Namm;
        }


        public void SayHello()
        {
            Console.WriteLine("大家好");
        }

    }
     class Person2
    {
        /*成员变量字段,属性,索引,代理,事件,嵌套类,方法。*/
         public static int age;
        public void SayHello() 
        {
            Console.WriteLine("dddd");
        }

        public int AddParams(params int[] number)
        {
            int sum = 0;
            foreach (int item in number)
            {
                sum += item;
            }
            return sum;
        }
    }
     public class Person3
     {
         private int age;
         public int Age
         {
             get { return age; }
             set { age = value; }
         }
         public int this[int a]
         {
             get { return age; }
             set { age = value; }
         }


     }
}

 

posted @ 2016-03-12 15:10  肆季风  阅读(1916)  评论(0编辑  收藏  举报