type TypeA() = class end
type TypeB() = inherit TypeA()
// "The type 'TypeA' does not match the type 'TypeB'":
let iDict : IDictionary<TypeA, bool> = [ TypeB(), true; TypeB(), false ] |> dict
let d = Dictionary<TypeA, bool>()
// This is OK, though:
d.Add (TypeB(), false)
왜 IDictionary 키는 파생 된 형식과 호환되지 않습니까? 두 방법의 차이점에IDictionary <_, > 키가 파생 된 유형과 호환되지 않는 이유는 무엇입니까?
바운드가 중복되지만 F #의 배열이 공변이지 않습니다. 추가와 같은 메소드 오버로드가 발생합니다. –
'KeyValuePair <'Key, 'Value>'가 'Key'에 대해 공변이지 않으므로? – ildjarn
관심 분야 : [Eric Lippert의 Erstwhile Blog - 키워드 : 공분산 및 Contravariance] (https://blogs.msdn.microsoft.com/ericlippert/tag/covariance-and-contravariance/) 참고 : 목록은 역순으로 나열되어 있으며, 그래서 끝에서 시작해서 앞으로 나아가 야합니다. –