在C#,我怎样才能把KeyValuePair给KeyValuePair?我尝试了以下几种方法,但都不起作用:
public static KeyValuePair<object, object> DoTheCast(KeyValuePair<string, object> the_obj)
{
return (KeyValuePair<object, object>)the_obj;
}'System.Collections.Generic.KeyValuePairSystem.String,:无法将‘System.Collections.Generic.KeyValuePairSystem.String,System.Object’类型的对象强制转换为'System.Collections.Generic.KeyValuePairSystem.Object,System.Object‘。
发布于 2019-04-28 00:04:05
您将无法投下perse,但是您可以创建一个新的
public static KeyValuePair<object, object> DoTheCast(KeyValuePair<string, object> the_obj)
=> new KeyValuePair<object, object>(the_obj.Key, the_obj.Value);https://stackoverflow.com/questions/55885888
复制相似问题