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(curren tLine);
//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?
}
}
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(curren
//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
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
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