Hi All,
I have been looking for some examples of how to call a a classes base constructor using a different argument than the derived class.
I have noted from the examples I have found that when calling the base class like so:
Code:
public MyDerivedClass(int myInt):base(myInt){}
The base class constructor is executed first.
I wish to use a SQLDatareader from the derived class constructor in the base class constructor.
Something like this:
Code:
public MyDerivedClass(int myInt)
{
//Call a method that selects returns a datareader containing the fields for the objects properties
SLQDataReader reader = this.Select();
if(reader.read())
{
//Set a few variables here
this.MyVariable = reader[""];
//Then I want to load the base class properties with fields from this reader.
base(reader);
}
}
But I get an error:
"Use of keyword base is not valid in this context."
So my question is: How do I call the base constructor explicitly???
Many thanks for taking the time to read this.
======================================
They say, best men are molded out of faults,
And, for the most, become much more the better
For being a little bad.
======================================