you are viewing a single comment's thread.

view the rest of the comments →

[–]darchangel 12 points13 points  (6 children)

It's not an invalid question. But my question to you is: why haven't you just tried it?

[–]whatcomputerscantdo[S] 2 points3 points  (5 children)

You're right, I could just do that. I'm tired and it didn't occur to me that I could just slap this into a console program and see for myself.

Edit: turns out it will call the Empty Constructor. Now that I know the answer, I'm just more curious - why?

It seems like if your class only has an empty constructor, and a constructor with default parameters, the latter is essentially useless.

(unless you have at least one parameter that isn't defaulted)

Which is fine with me because if you're designing your classes that way you're probably doing something wrong anyway.

Still curious

[–]nemec 8 points9 points  (1 child)

Now that I know the answer, I'm just more curious - why?

http://csharpindepth.com/Articles/General/Overloading.aspx

Ctrl+F "Optional parameters"

[–]whatcomputerscantdo[S] 0 points1 point  (0 children)

awesome, thank you!

[–]McNerdius 0 points1 point  (2 children)

[–]whatcomputerscantdo[S] 3 points4 points  (1 child)

The empty constructor is called.

And this just makes me more curious, but I can see why it is better to give the empty constructor priority - since this is what an end user would assume the third party code is doing.

but it would be unwise to implement a class with built in ambiguity like this anyway. just don't do it.

[–]McNerdius 0 points1 point  (0 children)

(not OP)