This is my main class person
public class Person
{
public void SetAge(int n)
{
n = 20;
}
static void Main(string[] args)
{
}
}
and i want to access the n variabe in this inherited class student
class student : Person
{
public void GoToClasses()
{
Console.WriteLine("I am going to class");
}
public void ShowAge()
{
Console.WriteLine("My age is {0}",n);
}
}
I tried using Person.n or SetAge(20) or SetAge(n) and it won't work !
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…