G
Gabriel Lozano-Morán
I have a questions about the correct usage of deriving from classes that are
not generic and where to place the generic constraints:
public class MRUItems<T> : NameObjectCollectionBase where T : IMRUItem
{
public T this[int index]
{
get { return BaseGet(index) as T; }
set { BaseSet(index, value); }
}
}
Following compile error:
The type parameter 'T' cannot be used with the 'as' operator because it does
not have a class type constraint nor a 'class' constraint.
Note:
I don't want to use a generic sorted list, I just want to know how to
correctly derive from NameObjectCollectionBase and add the generic
constraint T : IMRUItem.
Thanks
Gabriel
not generic and where to place the generic constraints:
public class MRUItems<T> : NameObjectCollectionBase where T : IMRUItem
{
public T this[int index]
{
get { return BaseGet(index) as T; }
set { BaseSet(index, value); }
}
}
Following compile error:
The type parameter 'T' cannot be used with the 'as' operator because it does
not have a class type constraint nor a 'class' constraint.
Note:
I don't want to use a generic sorted list, I just want to know how to
correctly derive from NameObjectCollectionBase and add the generic
constraint T : IMRUItem.
Thanks
Gabriel