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)”的可访问性低
出现错误!
这是书上的,但我不知道哪里错了???
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)”的可访问性低
出现错误!
这是书上的,但我不知道哪里错了???
解决方案 »
- 正则表达式,请大师帮忙解决
- visual studio有自动纠正警告的功能或插件吗
- c#.net中菜单项不需要图标时去掉菜单列表左侧空白,怎么干~
- Dinctionary 存盘的问题
- 如何让控件的大小与窗体大小成等比放大或缩小
- C#中如何通过应用程序的路径得到对应应用程序的图标放到listview里
- 释放此 System.Net.Sockets.TcpClient 实例,而不关闭基础连接 是什么意思?
- contextmenu 的二极菜单text动态修改无法显示
- 数据库内容加密
- 取出datagrid里面指定列的值
- 新人请教 c#中的href语句 真的看晕了
- 在Winform中ReportViewer画图控件如何通过按钮保存图片?
{
public void Add(string newId, people newpeople)
{
Dictionary.Add(newId,newpeople);
}
public void Remove(string newpeople1)
{
Dictionary.Remove(newpeople1);
}
public allpeople()
{
}
}
你要公开的话就全部公开,你把这个类的public 去掉试试看
allpeople是公开!
要么把上面的改公开,要么把下面的改私有!