属性设置的一些异常行为

using System;
using System.Collections;
namespace ConsoleEnum
{
    class Host
    {

        private const string DATA_ROOT_PTAH=@"..\..\data";
        public Student Student { get; set; }
        public virtual Instrument Instrument
        {
            get
            {
                return new Instrument() { ID = 1021, Symbol = "IF1309(玻璃)", };
            }
        }
        public Host()
        {
            Student = new Student();
            Student.Name = "MrGan";
            Student.Age = 23;
            Student.Address = "GuangXi";
        }
        [STAThread]
        static void Main(string[] args)
        {


            Console.ReadLine();
        }
    }


    class Student
    {

        public string Name { get; set; }
        public int Age { get; set; }
        public string Address { get; set; }

        public Student()
        {

        }
        public Student(string name,int age,string address)
        {
            this.Name = name;
            this.Age = age;
            this.Address = address;

        }
    }

    class Instrument
    {
        public string Symbol { get; set; }     
        public int ID { get; set; }
        public Instrument()
        {

        }
        public Instrument(string symbol)
        {
            this.Symbol = symbol;
        }

    }
}


 

posted @ 2013-05-14 19:31  Predator  阅读(146)  评论(0编辑  收藏  举报