[英]The type or namespace name 'MySql' could not be found (are you missing a using directive or an assembly reference?) c# VS 2013
[英]C#: The type or namespace name 'class' could not be found(are you missing a using directive for an assembly reference?)
class World
{
bool _playerHasWonGame = false;
public void Update()
{
Entity player = FindEntity("Player"); //ERROR: The type or namespace name 'Entity' could not be found(are you missing a using directive for an assembly reference?)
}
private Entity FindEntity(string p) //Same ERROR
{
throw new NotImplementedException();
}
}
class Inventory
{
public bool Contains(Entity entity)
{
return false;
}
}
public class Entity
{
public Inventory Inventory { get; set; }
}
错误部分是实体。
我创建了Entity类,并尝试在World类中创建Entity对象。
据我了解,它应该起作用。 我只是想像其他C#程序员一样制作对象。 但是,看来我的编译器找不到实体定义。
默认情况下,类不是公共的,因此与返回其实例的属性相比, Inventory
的访问性较低。
可以将Entity
更改为内部Entity
(这样它及其属性将与Inventory
处于同一范围内)或将Inventory
公开。
(通过更改任一代码段即可为我编译)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.