Tuesday, February 25, 2014

generic interface and method with additional type constraints

Quite a lot of trickery indeed. I didn't quite follow throughout your entire post but I think the additional constraint issue can be solved with an extension method:



public interface IGridColumn<TItem, TElement> {
}

public static class IGridColumnExtensions {
public static IGridColumn<TItem, TElement> Editable<TItem, TElement, TKey>(this IGridColumn<TItem, TElement> column // etc) where TItem : IHasId<TKey> {
...
}
}


No comments:

Post a Comment