Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/321.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 将动态类型参数引用的json强制转换为Idictionary_C#_Generics_Dynamic_Idictionary - Fatal编程技术网

C# 将动态类型参数引用的json强制转换为Idictionary

C# 将动态类型参数引用的json强制转换为Idictionary,c#,generics,dynamic,idictionary,C#,Generics,Dynamic,Idictionary,我遇到了以下不起作用的代码 public void Execute(dynamic options){ var dictionary = options as IDictionary<string,object>();//i saw the dictionary is always null but the developer is says it suppose to work! } 我的问题是,这是否可行?我的意思是,可以将动态类型引用的json强制转换为IDiction

我遇到了以下不起作用的代码

public void Execute(dynamic options){
   var dictionary = options as IDictionary<string,object>();//i saw the dictionary is always null but the developer is says it suppose to work!
}

我的问题是,这是否可行?我的意思是,可以将动态类型引用的json强制转换为IDictionary而不使用任何blackmagic吗?

您可以使用
对象
类型作为参数。或者实现一个动态字典。看一看:
[{Id :1212, Page : 12, SortColumn : "Name", SortBy : "ASC"}]