嗨我在C#编程方面有点新,而且我有点卡住了。我尝试过搜索这个网站,但是我没有找到答案来解决我的问题。我也尝试改变我的私人到公众,但没有奏效。不一致的可访问性
以下是错误消息我得到:
错误2可访问性不一致:参数类型 'exam2.location' 是 比方法 'exam2.Form1.MoveToANewLocation(exam2.location)' 不易进入
这里是我的代码部分:
public Form1()
{
IntializeComponent();
CreateObject();
MoveToANewLocation(livingRoom);
}
private void MoveToANewLocation(location newLocation)
{
currentLocation = newLocation;
comboBox1.Items.Clear();
for (int i = 0; i < currentLocation.Exits.Length; i++)
{
comboBox1.Items.Add(currentLocation.Exits[i].Name);
comboBox1.SelectedIndex = 0;
}
textBox1.Text = currentLocation.Description;
if (currentLocation is IHasExteriorDoor)
{
GoThroughTheDoor.Visible = true;
}
else
{
GoThroughTheDoor.Visible = false;
}
}
abstract class location
{
public location(string name)
{
this.name = name;
}
public location[] Exits;
private string name;
public string Name
{
get { return name; }
}
public virtual string Description
{
get {
string description = "You're standing in the" + name +
". You see exits to the following places: ";
for (int i = 0; i < Exits.Length; i++)
{
description += " " + Exits[i].Name;
if (i != Exits.Length - 1)
description += ",";
}
description += ",";
return description;
}
}
}
什么是地点类标记为? – BradleyDotNET
对于迟到的回复,我很抱歉,自从我参加该计划以来,我一直没有上网。我将位置类标记为“抽象类位置”。在所有的课程中,我公开发布了自己的代码,当我将它们设为私有时,我创建了一个'get'访问器,以便能够访问另一个类中的私有代码。非常感谢回复 – Hannah