修改现有集合 [英] Modifying Exsisting Collection

查看:70
本文介绍了修改现有集合的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



我有一个Sortedlist集合.在这种情况下,我想将一些值附加到现有键的值上.您能帮我吗?

例如:如果sortedlist [2] == true,则要将其他值附加到sortedlist [2]的值.

在此先感谢您,

Hi,

I have a Sortedlist Collection. In this i want to append some value to exsisting key''s value. Can you please help me on this?

e.g: if sortedlist[2] == true then want to append some other value to sortedlist[2]''s value.

Thanks in Advance,

推荐答案

如果您的键值对设置为< whatever,bool>如您的示例所示,那么您不能对其附加"任何内容:布尔值不能被附加".

您实际上想实现什么?
If your key-value pair is set as <whatever,bool> as your example seems to indicate, then you can''t "append" anything to it: a bool is not something that can be "appended to".

What are you actually trying to achieve?


foreach (DictionaryEntry item in sortedList)
    {
        if(item.Value == "[something]")
        {
          sortedList[item.Key] = item.Value + "[appendsomething]";
        }
    }


这篇关于修改现有集合的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆