using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Collections;
using System.Text.RegularExpressions;
using System.Threading;
using System.Data.SqlClient;
namespace ConsoleApplication18
{
    class Program
    {
        abstract class people
        {
            protected string name;
            public string Name
            {
                get
                {
                    return name;
                }
                set 
                {
                    name = value;
                
                }            
            }            public void speak()
            {                Console.WriteLine("O(∩_∩)O~,我是{0}",name);
            
            }        
        }
        class student : people
        {
            public student(string name)
                : base(name)
            { 
            
            }
            public void studentspeak()
            {
                Console.WriteLine("我是student,姓名:{1}",name);
            
            }        
        
        }
        class student1 : people
        {
            public student1(string name)
                : base(name)
            { 
             
            
            }            public void student1speak()
            {
                Console.WriteLine("我是student1,姓名:{1}", name);
            
            }
        
        }        public class allpeople : DictionaryBase
        {
            public void Add(string newId, people newpeople)
            {
                Dictionary.Add(newId,newpeople);
            
            }
            public void Remove(string newpeople1)
            {
                Dictionary.Remove(newpeople1);
            
            }
            public allpeople()
            {
            
            
            }
        
        }        static void Main(string[] args)
        {            allpeople mypeople = new allpeople();
            mypeople.Add("周华健",new student("我是谁"));
            mypeople.Add("周杰伦",new student1("我是周杰伦"));
            foreach (people op in mypeople)
            {
                Console.WriteLine("{0}",op.Name());
            }            Console.ReadKey();        }
    }
}
  
错误 1 可访问性不一致: 参数类型“ConsoleApplication18.Program.people”比方法“ConsoleApplication18.Program.allpeople.Add(string, ConsoleApplication18.Program.people)”的可访问性低
   出现错误!
   这是书上的,但我不知道哪里错了???

解决方案 »

  1.   

    public class allpeople : DictionaryBase 
            { 
                public void Add(string newId, people newpeople) 
                { 
                    Dictionary.Add(newId,newpeople); 
                
                } 
                public void Remove(string newpeople1) 
                { 
                    Dictionary.Remove(newpeople1); 
                
                } 
                public allpeople() 
                { 
                
                
                } 
            
            }
    你要公开的话就全部公开,你把这个类的public 去掉试试看
      

  2.   

    people这个类默认修饰符是私有!
    allpeople是公开!
    要么把上面的改公开,要么把下面的改私有!