C
C#2y ago
Darma

❔ What does it mean by inaccessible

I'm starting to learn about OOP, I'm wondering why I'm getting this error, what am I doing wrong?
5 Replies
jcotton42
jcotton422y ago
since you didn't include an access modifier when declaring Char's constructor, it defaulted to private same for the fields numOfLegs, rolling, and material you need to explicit make it public public Chair(int L, string M, bool R)
Darma
DarmaOP2y ago
Ah Thank you very much
jcotton42
jcotton422y ago
also, you should be using properties for public info not fields $structure
MODiX
MODiX2y ago
namespace Namespace;

[Attribute]
public class Class
{
public string PublicField;
private bool _privateField;
protected double protectedField;

public int PublicProperty { get; set; }

public Class() {} // Constructor

public void Method(int parameter)
{
var localVariable = parameter;
}
}
namespace Namespace;

[Attribute]
public class Class
{
public string PublicField;
private bool _privateField;
protected double protectedField;

public int PublicProperty { get; set; }

public Class() {} // Constructor

public void Method(int parameter)
{
var localVariable = parameter;
}
}
For C# versions older than 10, see $StructureOld
Accord
Accord2y ago
Was this issue resolved? If so, run /close - otherwise I will mark this as stale and this post will be archived until there is new activity.
Want results from more Discord servers?
Add your server