c# - How can I write a generic anonymous method? -


specifically, want write this:

public func<ilist<t>, t> selectelement = list => list.first(); 

but syntax error @ t. can't have generic anonymous method?

nope, sorry. require generic fields or generic properties, not features c# supports. best can make generic method introduces t:

public func<ilist<t>, t> selectionmethod<t>() { return list => list.first(); } 

and can say:

func<ilist<int>, int> selectints = selectionmethod<int>(); 

Comments

Popular posts from this blog

Add email recipient to all new Trac tickets -

400 Bad Request on Apache/PHP AddHandler wrapper -

php - Change action and image src url's with jQuery -