4 ms·
> In .NET, the usual convention is that you make required things constructor arguments, so that there's no room for confusion. Except in Windows Forms, where
by mwcampbell 6y ago
> In .NET, the usual convention is that you make required things constructor arguments, so that there's no room for confusion.
Except in Windows Forms, where the norm is a zero-argument constructor and setting everything via properties, because that approach works with component-based design-time tools. Come to think of it, I think WPF and its descendants do the same.
- ygra 6y agoYou can tell the designer how a particular type has to be created if it doesn't have a parameterless ctor, but yeah, it's generally easier to do it that way.
- mumblemumble 6y agoIt's been a while since I touched either WinForms or WPF, but, if I recall correctly how things worked, I don't think this is actually an exception to the convention. Don't they also make everything optional? In which case, the correct way to follow the pattern would be to also leave the constructor parameterless and configure everything via properties.