Link to home
Start Free TrialLog in
Avatar of Junoti
Junoti

asked on

How do you set derived props in addition to base props?

Hi all. I have a BaseClass with some properties that is common to all my class:

class BaseClass
{
  string BaseProperty
  {
    get{...;}
    set{...;}
  }

  protected static BaseClass<not sure if this is correct return type> ParseLine(string CurrentLine)
  {
    BaseClass baseClass = new BaseClass();
    baseClass.BaseProperty = "some value";
    return baseClass;
  }
}

And then a derived class with additional props, and a method that parses a file specific for this class:

class DerivedClass : BaseClass
{
  string SomeOtherProp
  {
    get{...;}
    set{...;}
  }

  public void SetFields(string FileName)
  {
    //Within FileName resides fields that are common to all base classes
    //It also has additional fields specific to this class
    //I need to be able to set the common fields in the base class, but also continue setting props for the derived class
   
    //this would be where I open the file and get the current line
   
    //Next step -- I think
    BaseClass someClass = BaseClass.ParseLine(currentLine);
   
    //NOW I want to be able to set the additional properties in this derived class but still keep the properties that were set in the ParseLine above
    //How the heck do I do it?    
  }
}
ASKER CERTIFIED SOLUTION
Avatar of eternal_21
eternal_21

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of 123654789987
123654789987

If u want to set the derived properties in addition to the base properties. Then u have to create an instance of the derived class. This will show all the properties - ones of the base cass and that of the derived class