与其说是解决方案,不如说是一种好奇心:
dynamic e = new ExpandoObject();
var value = 1;
var key = "Key";
var resul1 = RuntimeOps.ExpandoTrySetValue(
e,
null,
-1,
value,
key,
true); // The last parameter is ignoreCase
object value2;
var result2 = RuntimeOps.ExpandoTryGetValue(
e,
null,
-1,
key.ToLowerInvariant(),
true,
out value2); // The last parameter is ignoreCase
RuntimeOps.ExpandoTryGetValue/ExpandoTrySetValue
使用ExpandoObject
可以控制区分大小写的内部方法。null, -1,
参数取自ExpandoObject
(RuntimeOps
直接调用内部方法ExpandoObject
)内部使用的值
请记住,这些方法是This API supports the .NET Framework infrastructure and is not intended to be used directly from your code.