I have the following code.
public static void GuessTheType()
{
dynamic hasValue = true;
dynamic value = "true";
var whatami1 = hasValue ? (string)value : null;
var whatami2 = hasValue ? bool.Parse(value) : true;
var whatami3 = hasValue ? (bool)bool.Parse(value) : true;
}
The type inferred by the compiler for whatami1 is string.
The type inferred by the compiler for whatami2 is dynamic.
The type inferred by the compiler for whatami3 is bool.
Why is the second type not bool?