Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
这是我的代码:
JArray first; JArray second; JArray test = first.Union(second);
但它说它不能在 JToken 和 JArray 之间进行隐式转换?
因为联合会产生来自两个可枚举来源的不同值的可枚举结果。因此,第一个和第二个是IEnumerable<JToken>您正确的结果类型将是IEnumerable<JToken>:
IEnumerable<JToken>
IEnumerable<JToken> test = first.Union(second);
创建 JArray 很简单 - 它具有允许传递可枚举内容的构造函数:
JArray array = new JArray(first.Union(second));