I have an error in C#. My code gives the error
Inconsistent accessibility: field type 'Rotanet.RN_BUDGET_SETTINGS' is less accessible than field 'Rotanet.BudgetSettingsDetailFrm.aBudgetSettings'.
I know it is about PUBLIC/PROTECTED/PRIVATE modifiers, but I couldn't understand what I should do to fix it.
Here is my code that gives the error:
namespace Rotanet
{
public partial class BudgetSettingsDetailFrm : DevExpress.XtraEditors.XtraForm
{
public RN_BUDGET_SETTINGS aBudgetSettings = null; //***** this gives the error
public BudgetSettingsDetailFrm()
{
InitializeComponent();
}
private void btnSave_Click(object sender, EventArgs e)
{
}
}
}
and the RN_BUDGET_SETTINGS is a simple class like below...
namespace Rotanet
{
class RN_BUDGET_SETTINGS : RN_AUDIT
{
public RN_BUDGET_SETTINGS()
{
}
#region Properties
[IsKey(true)]
public dynamic ID { get; set; }
public dynamic TANIM { get; set; }
public dynamic DEGER { get; set; }
#endregion
}
}
How can I fix this problem?
You need to define the RN_BUDGET_SETTINGS
class as being Public
:
public class RN_BUDGET_SETTINGS : RN_AUDIT
{
}
or define the aBudgetSettings as internal/private:
private RN_BUDGET_SETTINGS aBudgetSettings = null;
Your problem is that you have defined a public field so it is visible outside your project, however the class that you can read/write to the field isn't public. Externally this means you can set a value, but you've not been told the contract/information about the thing you can set.