![](/img/trans.png)
[英]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.