Let's say I have a method like this:
public void Foo(object arguments)
and say that I need to determine if the type arguments
is really an enumeration. I would write something like this:
if (arguments is IEnumerable)
Now let's say I need to determine if this is an enumeration of KeyValuePair (regardless of the type of key and type of value). My instinct would be to write something like this:
if (arguments is IEnumerable<KeyValuePair<,>>)
but visual studio complains that Using the generic type 'KeyValuePair<TKey, TValue>' requires 2 type arguments
.
I also tried:
if (arguments is IEnumerable<KeyValuePair<object, object>>)
but returns false if the key is something like an object (for example string
), or if the value is something like an object (for example int
).
- , , KeyValuePairs , , ?