M
Mike Labosh
Greetings, all:
I want to invoke one constructor from another to gain code reuse.
In the snip below, I want my second constructor to pass its first argument
to the first constructor so that the first constructor can set the Provider
property and invoke the resetConnection() method first, before the second
constructor assigns the connection string to the Connection property, but I
can't seem to work out the syntax.
public class DataProcessor {
// all unrelated code omitted.
public DataProcessor(DataProvider provider) {
Provider = provider;
resetConnection();
}
public DataProcessor(DataProvider provider, string connectionString) {
// this.DataProcessor(provider); <-- How do I do this?
Connection.ConnectionString = connectionString;
}
}
I want to invoke one constructor from another to gain code reuse.
In the snip below, I want my second constructor to pass its first argument
to the first constructor so that the first constructor can set the Provider
property and invoke the resetConnection() method first, before the second
constructor assigns the connection string to the Connection property, but I
can't seem to work out the syntax.
public class DataProcessor {
// all unrelated code omitted.
public DataProcessor(DataProvider provider) {
Provider = provider;
resetConnection();
}
public DataProcessor(DataProvider provider, string connectionString) {
// this.DataProcessor(provider); <-- How do I do this?
Connection.ConnectionString = connectionString;
}
}