You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Would it make sense to allow explicit access to method groups, without a class instance?
Examples:
classFoo{publicvoidBar(){}publicintBaz{get;set;}publiceventEventHandlerPoke;}classProgram{publicstaticvoidMain(){Action<Foo>bar=Foo.Bar;Func<Foo,int>bazGetter=Foo.Baz.get;Action<Foo,EventHandler>pokeAdder=Foo.Poke.add;Foof=newFoo();bar(f);// Equivalent to f.Bar();intb=bazGetter(f);// Equivalent to int b = f.Baz;pokeAdder(f,(sender,e)=>{});// Equivalent to f.Poke += (sender, e) => { };}}
I know that all three forms can be written right now, like this:
Action<Foo>bar= f =>f.Bar();Func<Foo,int>bazGetter= f =>f.Baz;Action<Foo,EventHandler>pokeAdder=(f,h)=>f.Poke+=h;
but the syntax above would be nicer (and probably better for the type inference, because Foo.Bar has an obvious type, whereas f => f.Bar() needs a type annotation).
The text was updated successfully, but these errors were encountered:
Would it make sense to allow explicit access to method groups, without a class instance?
Examples:
I know that all three forms can be written right now, like this:
but the syntax above would be nicer (and probably better for the type inference, because Foo.Bar has an obvious type, whereas f => f.Bar() needs a type annotation).
The text was updated successfully, but these errors were encountered: