Click here to Skip to main content
15,888,286 members
Please Sign up or sign in to vote.
3.00/5 (2 votes)
See more:
Can someone please explain what is the meaning of highlighted line?
C#
public  abstract class Class1
  {
      protected double a;

      public virtual double Getval()
      {
          return this.a;
      }
  }

  public class Class1A : Class1
  {
      public Class1A()
      {
          this.a = 6.99;
      }
  }

  public abstract class Class1B : Class1
  {
      protected Class1 Obj;
      public Class1B(Class1 instance)
      {
          this.Obj = instance;
      }

      public override double Getval()
      {
          return (this.Obj.Getval() + this.a);
      }
  }

  public class Class1B1 : Class1B
  {
      public Class1B1(Class1 tbd)  : base(tbd) // What is this? please explain
      {
          this.a = 0.99;
      }
  }


What I have tried:

C#
public class Class1B1 : Class1B
    {
        public Class1B1(Class1 tbd)  : base(tbd) // What is this? please explain 
        {
            this.a = 0.99;
        }
    }
Posted
Updated 2-Apr-16 7:31am
v2
Comments
PIEBALDconsult 2-Apr-16 13:40pm    
Instance Constructors (C# Programming Guide)
https://msdn.microsoft.com/en-us/library/k6sa6h87.aspx
Sergey Alexandrovich Kryukov 2-Apr-16 15:50pm    
Bad idea. This is not how you can learn technology and languages. Take a manual and read it all. Answering such questions by "explaining" code (what would it supposed to mean?) cannot really help you.
—SA

1 solution

check out this perfect explanation from msdn
base keyword[^]
c# base [^]

one line explanation
whenever an instance (object) is created for Class1B1, the base class Class1B 's constructor will be initiated with the same parameter tbd (class1's object)
 
Share this answer
 
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900