1
私は以下のメソッドを使用していますが、Dictionary
ではTKey
を返します。 Dictionary
ICollection<KeyValuePair<TKey,TValue>>
を実装する方法を教えてください。 KeyValuePair<TKey,TValue>
?ICollectionの汎用型を取得します
public static Type GetCollectionGenericType(this Type type)
{
foreach(Type interfaceType in type.GetInterfaces())
{
if(interfaceType.IsGenericType &&
interfaceType.GetGenericTypeDefinition() == typeof(ICollection<>))
{
return type.GetGenericArguments()[ 0 ];
}
}
return null;
}