[英]Changing an element in a dictionary value array in c#
Say I have a Dictionary<int, string[]> dict
. 说我有一个
Dictionary<int, string[]> dict
。 How could I change a specific element in a string[] in that dictionary, while keeping the others the same? 如何在该词典中更改string []中的特定元素,同时保持其他元素不变? I tried something like this
我尝试过这样的事情
dict[0].ElementAt(0) = "Something Different";
but the left hand side isn't a variable/property/indexer. 但左侧不是变量/属性/索引器。
ElementAt
只是一个访问器,它不支持分配,您应该尝试直接索引访问,例如:
dict[0][0] = "Your String";
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.