0

I have the following two constructors in my base class:

protected ExternalSystemException( params Object[] args ) 
    : this( null, null, args ) {}

protected ExternalSystemException( String propertyKeySuffix, 
    params Object[] args ) : this( propertyKeySuffix, null, args ) {}

My child class has the following constructor:

public InvalidPathToOutputFiles(string invalidPath) 
    : base(invalidPath) {}

My client logic instantiates the child class like so:

throw new ChildClass( "goofy" );

When I step through the logic I unexpectedly end up at the base constructor with the parameters ( String propertyKeySuffix, params Object[] args ). I expected the other base class constructor to be called, namely ( params Object[] args ).

Can someone tell me why this is happening?

1
  • As soon as I hit submit I wanted to take this one back. Commented Aug 18, 2010 at 21:24

1 Answer 1

8

The string overload is the best match to the type you are providing to the constructor. The Params are optional (and Object is ambiguous), so since the second overload has a string type that matches the string type you are passing, the second overload is selected.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.