Why can't I do something like this:
var myDictionary = new Dictionary<string, Type>();
// Add data to dictionary
foreach(var kvPair in myDictionary)
{
var result = SomeMethod<kvPair.Value>(kvPair.Key); // Error
}
So I cannot use the Type that I have in the Dictionary element and use it in the type parameter. Yes I could just send the dictionary to the SomeMethod(KeyValuePair). However I do not have control of how the function is implemented.
Error: The type or namespace name 'kvPair' could not be found (are you missing a using directive or an assembly reference?
I feel like I am missing something pretty foundational and I am not sure what it is.