What do nested generics mean in c #?

A bit of a fundamental question, but nonetheless that seems to stun me.

Given the "nested generic":

IEnumerable<KeyValuePair<TKey, TValue>>

Is this a statement that IEnumerable can have common types that themselves are KeyValuePair?

Thank,

Scott

+5
source share
4 answers

Yes. The KeyValuePair type expects two typical types. We can either fill them out by pointing to specific types:

IEnumerable<KeyValuePair<string, int>>

Or we can populate them using other common parameters already specified by the external class:

class Dictionary<TKey, TValue> : IEnumerable<KeyValuePair<TKey, TValue>>

" " , , . , , , ( ) .

+6

, "IEnumerable /". :

IEnumberable<KeyValuePair<string, string>> reallyComplicatedDictionary =
    new IEnumerable<KeyValuePair<string, string>>();

.

, , , "" .

+1

, IEnumerable, KeyValuePair<TKey, TValue> ( TKey TValue).

, .

+1

IEnumerable<KeyValuePair<string, int>>

IEnumerable . , KeyValuePair. KeyValuePair , 2 .

0

All Articles