2012-07-13 2 views
0

은 내가 _Conditions의 IEnumerable을 정의 컴파일 오류가 계속이왜이 일반 인터페이스 정의가 잘못 되었습니까?

public interface IPropertyGroupCollection 
{ 
    IEnumerable<IPropertyGroup> _Propertygroups { get;} 
} 

public interface IPropertyGroup 
{ 
    IEnumerable<IProperty<T, U, V>> _conditions { get; } 
} 

public interface IProperty<T, U, V> 
{ 
    T _p1 { get; } 
    U _p2 { get; } 
    V _p3 { get; } 
} 

public class Property<T, U, V> : IProperty<T, U, V> 
{ 
    //Some Implementation 
} 

같이 보입니다 인터페이스를 작성하려합니다.

내가 뭘 잘못하고 있니? 아이디어는 구현하는 클래스는 T, U 및 V를 선언하지 않은 그것 때문에 일반적인 속성 모음 모음

+0

이 object''모든 제네릭를 교체하고 사용자가 설정된다. – ja72

답변

7

을 될 것입니다 :

public interface IPropertyGroup<T, U, V> 
{ 
    IEnumerable<IProperty<T, U, V>> _conditions { get; } 
} 

당신은뿐만 아니라 IPropertyGroupCollection에 일반적인 유형을 추가해야합니다.

IProperty<bool,bool,bool>은 동일한 일반 '템플릿'에서 왔음에도 불구하고 IProperty<int,int,int>과 다른 유형입니다. IProperty<T, U, V> 컬렉션을 만들 수 없으며 IProperty<bool, bool, bool> 또는 IProperty<int int, int> 컬렉션 만 만들 수 있습니다.

UPDATE :

public interface IPropertyGroupCollection 
{ 
    IEnumerable<IPropertyGroup> _Propertygroups { get;} 
} 

public interface IPropertyGroup 
{ 
    IEnumerable<IProperty> _conditions { get; } 
} 

public interface IProperty 
{ 
} 

public interface IProperty<T, U, V> : IProperty 
{ 
    T _p1 { get; } 
    U _p2 { get; } 
    V _p3 { get; } 
} 

public class Property<T, U, V> : IProperty<T, U, V> 
{ 
    //Some Implementation 
} 
+0

그럼 어떻게 컬렉션을 PropertyBag로 사용할 수 있습니까? 컬렉션 인터페이스에 제네릭 형식을 추가하면 어떻게됩니까? – SudheerKovalam

+0

글쎄, 당신은 당신이 그들을 사용하려는 방식으로 제네릭을 사용할 수 없습니다. –

+0

그래서 속성 가방처럼 작동하는 인터페이스를 정의 할 수있는 방법이 있습니까? – SudheerKovalam

관련 문제