I (lazily) used varin the source version of the code below and got a weird run-time exception in a completely different part of the code. Changing "var" to "int" fixed an exception at runtime, but I can't figure out why. I threw the code back to this example;
public class Program
{
private static List<string> Test(string i) { return new List<string> {i}; }
private static dynamic GetD() { return 1; }
public static void Main()
{
int value1 = GetD();
var result1 = Test("Value " + value1);
Console.WriteLine(result1.First());
var value2 = GetD();
var result2 = Test("Value " + value2);
Console.WriteLine(result2.First());
}
}
I can see that the type "var" is dynamic, not int, but why does this type propagate and affect the behavior of the return value of the call on Test()?
EDIT: , ; , dynamic result2, , , IDE , List<string> Test(string) - , . , IDE , ?