我现在还在学习C#中 `看到红皮书的第11章 `
做到后面的练习中有个地方想问
public class Person
    {
        private string name;
        private int age;        public string Name
        {
            get
            { 
                return name;
            }
            set
            { 
                name =value ;
            }
        }        public int Age
        {
            get
            {
                return age ;
            }
            set
            {
                age = value;
            }
        }
        public Person(string newName,int newAge)
        {
            Name = newName;
            Age = newAge;
        }
    }    public class people :DictionaryBase 
    {
        public void Add(string personID,Person newperson)
        {
            Dictionary.Add(personID, newperson);
        }        public void Remove(string personID)
        {
            Dictionary.Remove(personID);
        }        public people()
        {
        }        public Person this[string personID]
        {
            get
            {
                return (Person)Dictionary[personID];
            }
            set
            {
                Dictionary[personID] = value;
            }
        }
    }    class Program
    {
        static void Main(string[] args)
        {
            people peopleTOP = new people();
            peopleTOP.Add("john", new Person("john",19));
            peopleTOP.Add("lannet",new Person("lannet",20));
            foreach (DictionaryEntry  mypeople in peopleTOP)
            {
                //为什么这里用下面的这种方法就可以而我用
                //Console.WriteLine(((Person )mypeople .Value ).Name,((Person )mypeople .Value ).Age);
                // 不会产生问题却不能显示出age的值?
                Console.WriteLine(((Person )mypeople .Value ).Name);
                Console .WriteLine (((Person )mypeople .Value ).Age);
            }
        }
    }

解决方案 »

  1.   

    Console.WriteLine("Name={0},Age={1}",   ((Person )mypeople .Value ).Name,((Person )mypeople .Value ).Age);
      
    *****************************************************************************
    欢迎使用CSDN论坛阅读器 : CSDN Reader(附全部源代码) 
    http://www.cnblogs.com/feiyun0112/archive/2006/09/20/509783.html
      

  2.   

    追问`为什么一定要有个“”内容`而不能直接打出?是不是Console.WriteLine 里面有2个参数以上的都要用这样`?