So here is my problem:
I have the interface:
public interface ICell<Feature>
where Feature: struct, IComparable<ICell<Feature>>
{
List<ICell<Feature>> Window { get; set; }
Feature GenusFeature { get; set; }
Double VitalityRatio { get; set; }
String PopulationMarker { get; set; }
Boolean Captured { get; set; }
}
And wanted to implement ISubstratum interface in this way:
public interface ISubstratum<K,T> : IDisposable
where K : IDisposable
where T : struct
{
ICell<T> this[Int32 i, Int32 j] { get; set; }
}
But compiler says that:
The type 'T' cannot be used as type parameter 'Feature' in the generic type or method 'Colorizer.Core.ICell<Feature>'. There is no boxing conversion or type parameter conversion from 'T' to 'System.IComparable<Colorizer.Core.ICell<T>>'.
In some possible ISubstratum implementation I planned to pass a Bitmap as K && ICell (extented pixel info) as T.
How to resolve this?
Thanks!
Basically you've got to have an extra constraint on T:
where T : struct, IComparable<ICell<T>>
then it should work fine. That's required to satisfy the same constraint on Feature in ICell<Feature>.
I would also suggest you rename the type parameter Feature to TFeature to make it more obviously a type parameter.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With