C
C#2y ago
Musluk

❔ empty constructor

what's the point of using empty constructor method like this
12 Replies
LPeter1997
LPeter19972y ago
In this case, nothing But an empty constructor can still be somewhat useful, like making it private for ex
Musluk
MuslukOP2y ago
so this is a default thing whether I write or not
LPeter1997
LPeter19972y ago
Yes
TheBoxyBear
TheBoxyBear2y ago
And depending on when that code was made, it could have been a necessity. Auto constructors are still pretty new
LPeter1997
LPeter19972y ago
Implicit default constructors are C# 1.0
TheBoxyBear
TheBoxyBear2y ago
huh I swear I read about it being a new feature just years back .net 5 or 6
LPeter1997
LPeter19972y ago
There's no such thing as auto-constructors either as far as I'm aware
TheBoxyBear
TheBoxyBear2y ago
Made up the term
LPeter1997
LPeter19972y ago
The newest thing I can think of are record ctors with the primary ctor style
reflectronic
reflectronic2y ago
for structs, the ability to declare a default constructor is very new for classes, if you do not declare any constructors, C# will generate public X() { /* Do nothing */ } for you, and it has always been that way
TheBoxyBear
TheBoxyBear2y ago
That must be the one I heard of then
Accord
Accord2y ago
Was this issue resolved? If so, run /close - otherwise I will mark this as stale and this post will be archived until there is new activity.
Want results from more Discord servers?
Add your server