If you have a base class for all objects that the class handles, then
you don't need to use generics at all in your class. Just use the base
class when you inherit the BindingList.
public abstract class BaseList : BindingList<BaseObject>
Now your BaseList is a BindingList that handles any object that inherits
from BaseObject.
In your method that loops the items, just reference them as BaseObject:
public void AcceptChanges() {
foreach (BaseObject item in this.Items) {
item.ObjectState = ObjectState.Unchanged;
}
DeletedRows.Clear();
}
alee via DotNetMonster.com wrote:
> Hi Goran,
>
> Thanks. The using syntax works, but I still have problem converting the
> definition
> for the generic T. I
>
> public abstract class BaseList<T of BaseObject> : BindingList<T>
>
> - I want the generic key argument inherits properties defined in BaseObject.
>
> Originaal VB.NET syntax is:
>
> Public MustInherit Class BaseList(Of T As BaseObject) Inherits BindingList(Of
> T)
>
> Cheers,
>
> Alan L.
>
>
> Göran Andersson wrote:
>>> - Visusal Studio error: 'T' does not contain a definition for 'ObjectState'
>> C# is case sensetive while VB is not. Have you checked the exact name,
>> so it isn't for example "objectState"?
>>
>>> - my approach:
>>>
>> [quoted text clipped - 5 lines]
>>> Syntax error, '(' expected
>> using (txScope) {
>> ...
>> }
>>
>
--
Göran Andersson
_____
http://www.guffa.com