그래서 인터페이스가 있습니다.
interface A<SomeType>
{
SomeType Abc(SomeType);
.....
}
그리고 수업이 있습니다.
class B<ShouldBeClassA<AnyType>>
where ShouldBeClassA<AnyType> : A<AnyType>
{ ShouldBeClassA<AnyType> someVariable; .....}
하지만 이것은 구문 오류의 원인이며, 내가 원하는 것은 someVariable이 파생되도록 강제하는 것입니다.
A<AnyType>
그래서 할 수 있습니다.
class B......
{
....
void Method()
{
someVariable.Abc(anyTypeVariable);
}
......}
u pls는 그것을 고치는 방법을 말해 줄 수 있습니까?
실제 코드는 다음과 같습니다.
public interface IGenericTeacher<Genome<GenomeType>>
where Genome<GenomeType> : IGenome<GenomeType>
{
/// <summary>
/// Pass the tests and save the results.
/// </summary>
void PassTests();
/// <summary>
/// Passing generation, according to the results.
/// </summary>
void PassGeneration();
}
public interface IGenome<GenomeType>
{
.......
인터페이스는 다음과 같아야합니다.
public interface IGenericTeacher<T> where T : IGenome<T>
{
//...
}
이 기사는 인터넷에서 수집됩니다. 재 인쇄 할 때 출처를 알려주십시오.
침해가 발생한 경우 연락 주시기 바랍니다[email protected] 삭제
몇 마디 만하겠습니다