开发者

Load from Properties.Settings to ArrayList?

开发者 https://www.devze.com 2022-12-13 05:01 出处:网络
Here is the settings file that is leftover from saving. (Saving the properties works correctly.) <setting name=\"AlarmList\" serializeAs=\"Xml\">

Here is the settings file that is leftover from saving. (Saving the properties works correctly.)

<setting name="AlarmList" serializeAs="Xml">
<value>
    <ArrayOfAnyType xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
        xmlns:xsd="http://www.w3.org/2001/XMLSchema">
        <anyType xsi:type="ArrayOfAnyType">
            <anyType xsi:type="xsd:dateTime">2009-12-04T02:00:00</anyType>
            <anyType xsi:type="xsd:string">string1</anyType>
            <anyType xsi:type="xsd:string">string2</anyType>
        </anyType>
        <anyType xsi:type="ArrayOfAnyType">
            <anyType xsi:type="xsd:dateTime">2009-12-04T03:00:00</anyType>
            <anyType xsi:type="xsd:string">string1</anyType>
            <anyType xsi:type="xsd:string">string2</anyType>
        </anyType>
    </ArrayOfAnyType>
</value>
开发者_如何学Python

How can I load this back into the app using ArrayList? This is how I saved it.

ArrayList list = new ArrayList();
list.Add(SetAlarm.Value);
list.Add("string1");
list.Add("string2");
Settings.AlarmList2.Add(list);
Settings.Save();

Anyone know how I can use this to load the data from the settings?


I haven't tested this, but I think you can do:

ArrayList all = Settings.AlarmList2;
foreach (ArrayList items in all) {
     // items [0] -> DateTime
     // items [1] -> string1
     // items [2] -> string2
}
0

精彩评论

暂无评论...
验证码 换一张
取 消