Help with parameter usage
I have the following classes defined (code redacted for brevity)
Using .NET8 c#12
Which in turn is inherited by:
And in turn is inherited by:
Which has a
But the parameter
My covariance and/or contravariance games are shite, so i dont quite see where im going wrong, any help?
Using .NET8 c#12
public interface ICollectionItem
{}Which in turn is inherited by:
public class CollectionItem : NotifyPropertyChanged, ICollectionItem
{}And in turn is inherited by:
public class DeviceItem : CollectionItem, IDisposable, IAsyncDisposable
{
public DeviceItem(DeviceCollectionBase<ICollectionItem> deviceCollection)
{}
}Which has a
constructor so i can then create a DeviceItem instance from within yet another class:public abstract class DeviceCollectionBase<T> : PacedItemCollection<T>, IDisposable, IAsyncDisposable where T : ICollectionItem
{
protected override async Task UpdateCollection()
{
var v = new DeviceItem(this)...
}
}But the parameter
this is flagged with the error CS1503 "Argument type DeviceCollectionBase<T>, is not assignable to parameter type DeviceCollectionBase<ICollectionItem>" , yet T is constrained to be an ICollectionItem!My covariance and/or contravariance games are shite, so i dont quite see where im going wrong, any help?
