You can access it from inside a method like this:
public class MyClass2: MyClass
{
private void MyMethod()
{
x=1;
}
}
Or from a different class:
var test = new MyClass2();
test.x = 1;
If you intend for your x
field to be public, you should consider changing it to a property and capitalizing it, like this:
public int X { get; set; }
You can read about the difference between fields and properties here. If you do make it a property, be sure to follow Microsoft design guidelines and use PascalCase. See here.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…