その場合のエラーを理解するのを手伝ってもらえますか?
public interface IGeneralInterface
{
}
public class A : IGeneralInterface
{
}
public class B : IGeneralInterface
{
}
public class SomeClass<TGenericType> where TGenericType : IGeneralInterface
{
private TGenericType internalValue;
public SomeClass(TGenericType InitValue)
{
internalValue = InitValue;
}
public TGenericType CreateAnother()
{
TGenericType val1 = new B(); //Error here: class B() could not be converted to TGenericType
return val1;
}
}
SomeClass<T>
asをビルドしても
SomeClass<IGeneralInterface> someClass = new SomeClass<IGeneralInterface>();
すべての(?)ケースを含めるために明示的にベースインターフェイスを渡しますが、それでもエラーがスローされます