title: C# - How can I access the value using properties of classes in an override method?
body: <p>My Code:</p>
  
  <pre><code>public class A
  {
  
      public virtual void displayDetailInfo()
      {
      }
  
  }
  </code></pre>
  
  <hr>
  
  <pre><code>public class B : A
  {
  
      public String _a;
      public int _n;
  
      public B() { }
      public B(String _a, int _n)
      {
  
          this._a = _a;
          this._n = _n;
      }
  
      public String A
      {
          get { return _a; }
          set { this._a = value; }
      }
      public int N
      {
          get { return _n; }
          set { this._n = value; }
      }
  
      public override void displayDetailInfo()
      {
          Console.WriteLine(A);//To obtain value entered in Main(i.e. f.A)
          Console.WriteLine(N);//To obtain value entered in Main(i.e. f.N)
      }
  }
  </code></pre>
  
  <hr>
  
  <pre><code>public class Program
  {
  
      public static void Main(String[] args)
      {
          A v = new A();
          A v1 = new B();
          B f = new B();                            
              f.A = Console.ReadLine();  //Value to be accessed          
              f.N = Convert.ToInt32(Console.ReadLine());  //Value to be accessed 
              v1.displayDetailInfo();
      }
  }
  </code></pre>
  
  <p>How can I get the value(f.A and f.N) I entered in Main accessed from the overrided method in class B(i.e. displayDetailInfo()). The code I wrote doesn't obtains any value(i.e. Console.WriteLine(A) gives no value of f.A). So how can I get the value of f.A and f.N from overrided displayDetailInfo()? </p>