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
Post a Comment