-
When dealing with methods which accept a For instance, the following code is valid: var evenNumbers = Enumerable.Range(1, 10).Where(int.IsEvenInteger); // 2, 4, 6, 8, 10 This particular example uses a static method, but member methods are also permitted. In this example, the However, there is no similar use case for accessing static CTORs. In a use case I use fairly commonly, I may want to transform one type into another with IEnumerable<DirectoryInfo> childDirectories =
Directory
.EnumerateDirectories(@"C:\Temp\Foo")
.Select(it => new DirectoryInfo(it)); In this particular example, I could simply modify the code to be What I would like to do is to be able to pass a static reference to the ctor, just as I can with Proposed SyntaxOption 1 is to take inspiration from Kotlin. I propose Option 2 is to take inspiration from static functions. I propse I'm definitely open to other syntax suggestions, but ideally I'd like to maximise backwards compatibility. I'd imagine that, if properly designed, this is just syntax fluff over existing functionality and should in theory be compatible with any version of the language that supports |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
Duplicate of dotnet/csharplang#674. Also, please make sure that you're opening language suggestions on the csharplang repo, not on roslyn. Thanks! |
Beta Was this translation helpful? Give feedback.
Duplicate of dotnet/csharplang#674. Also, please make sure that you're opening language suggestions on the csharplang repo, not on roslyn. Thanks!