2013-11-27 47 views
1

我已經在論壇中查找了我的問題,並說了一些關於它的私人內容,但我已將所有方法和類都公開,但仍然出現此錯誤:與公共領域不一致的可訪問性錯誤

Error1 Inconsistent accessibility: field type ' A_Day_at_the_races.Bet ' is less accessible than field ' A_Day_at_the_races.Guy.MyBet '

這是我的代碼:

public class Guy 
{ 
    public string Name; // The Guy's name 
    public Bet MyBet; // An instance of Bet() that has his bet 
    public int Cash; //How much cash he has 
    // GUI controls on the form 
    public RadioButton MyRadioButton; // My RadioButton 
    public Label MyLabel; // My Label 
} 
+0

向我們展示Bet類的定義。 –

回答

3

它看起來像你的Bet類型聲明爲內部。要麼你明確地聲明它是內部的,要麼你沒有提供任何可訪問性修飾符,默認情況下它會被認爲是內部的。

嘗試使你的Bet類型的公共代替:

public class Bet { ... } // or public struct Bet/public interface Bet 

然後,您可以用它來申報等公共類型的公共成員:

public class Guy 
{ 
    public Bet MyBet; // or public Bet MyBet { get; set; } to create a property 
    ... 
} 

進一步閱讀

+0

嗨,感謝您的回覆,但我無法將它變成一個班級,因爲我會收到很多錯誤 – user3043427

+3

@ user3043427它是一個界面嗎?結構?沒關係,只是公開。 – dcastro

+0

@ user3043427你會得到什麼錯誤? –