In C# I can have references of methods and static methods. Can I also get the reference of a classes constructor?
In Java I can say Supplier<MyClass> createMyClass = MyClass::new
(instead of the longer lambda syntax).
In C# I only know the notation Func<MyClass> createMyClass = () => MyClass()
. But I think the Java way with the constructor reference is better readable.
And I don't want to make a static CreateMyClass
function. I really want the constructor.
No, there's no equivalent of method group conversions for constructors, or properties, indexers or operators.
It's an entirely reasonable idea, but it isn't in C# at the moment. It is, however, tracked as part of a feature request in the C# design repo - so you may want to subscribe to that issue.
See more on this question at Stackoverflow