Questions tagged «dynamictype»

3
做短路操作员|| 和&&是否存在可为空的布尔值?RuntimeBinder有时会这样认为
我阅读了有关条件逻辑运算符 ||和的C#语言规范&&,也称为短路逻辑运算符。对我来说,似乎还不清楚这些是否存在可空布尔值,即操作数类型Nullable<bool>(也写为bool?),因此我尝试使用非动态类型: bool a = true; bool? b = null; bool? xxxx = b || a; // compile-time error, || can't be applied to these types 这似乎解决了这个问题(我无法清楚地理解规范,但是现在我知道,假设Visual C#编译器的实现是正确的)。 但是,我也想尝试dynamic绑定。所以我尝试这样做: static class Program { static dynamic A { get { Console.WriteLine("'A' evaluated"); return true; } } static dynamic B { get …
By using our site, you acknowledge that you have read and understand our Cookie Policy and Privacy Policy.
Licensed under cc by-sa 3.0 with attribution required.