-1
C#에 대한 지식이 거의 없습니다.인터페이스, 제네릭, C#
다음 작업을 수행하는 올바른 방법은 무엇입니까?
목표는 다양한 구조체에서 작동 할 수있는 getvalue()
으로 인터페이스를 만드는 것입니다.
public interface IBOB<T> where T:struct
{
T GetValue();
}
다음
YAY:IBOB<bool>
을하고 지원하는 다른 어떤 종류 : 때문에/해상도를 이름에, 당신이해야 할 수도
class YAY : IBOB<bool>
{
public bool GetValue()
{
return true;
}
}
참고
public interface IBOB
{
T GetValue<T>() where T:struct
}
class YAY:IBOB
{
public bool GetValue<bool>()
{
return true;
}
}
자세한 정보가 필요합니다. – Greg