I built two different classes and I want that one class get inherit from another ,
but when I build Constructions Compiler throw me an Error.
I get to conclusion that i must use base function
so I build Constructor like this one :
public name_class:base()
my question what do I put between parentheses and if my syntax o.k and what is the right way to built such constructor

Thanks, sergey

9 Years
Discussion Span
Last Post by polo_coins

Have you tried:

public class Child : Parent

It's O.K. this thing I understand I mean syntax of building Constructors and call for Metgods of parents, I tried a couple things and here what I got :
public Name_of Chuld (type_of_variable name_of_it):base(name_of_this_variable_in_Parent)

and when I call for parent function :

are the other way of doing so, and how it will look like for calling Parent function that get's some variables from Main for example ?

Thanks Sergey


OK but if you had

class MyClass
   private int myval =0;
   public MyClass (int value)

  public int MyValue
     return myval;

You would call this in your inherited with

public MyNewClass : MyClass

  public int MyNewValue : base MyValue(1)


This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.