lambda - C# Extension methods on "members" -


i have extension methods used this:

mytype myobject;  string displayname = myobject.getdisplayname(x => x.property); 

the problem here needs instance, if extension method needs type mytype. if there no instance, needs called this:

string displayname = blahblahutility.getdisplayname((mytpe x) => x.property); 

which not nice anymore.

is there way write better syntax such cases?

what want (pseudo language):

string displayname = mytype.property.getdisplayname() 

which of course not work c#.

but this:

string displayname = ((mytype x) => x.property).getdisplayname(); 

this not possible (after lambda, dot not accepted).

any ideas?


edit:

my "favorite syntax" mytype.property.getdisplayname() seems misleading. don't talk static properties here. know syntax won't possible. tried show in pseudo language, information necessary. ideal, every additional stuff syntactical overhead. working syntax close great.

i don't want write extension method. want easy, readable , compile time safe syntax, using language feature.

have @ express , reflect classes in lokad shared libraries. think may out trying do. read more here:


Comments

Popular posts from this blog

C#: Application without a window or taskbar item (background app) that can still use Console.WriteLine() -

c++ - Convert big endian to little endian when reading from a binary file -

openssl - Load PKCS#8 binary key into Ruby -