2

这是保存后剩余的设置文件。(保存属性可以正常工作。)

<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>

如何使用 ArrayList 将其加载回应用程序?我就是这样保存的。

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

有人知道我如何使用它从设置中加载数据吗?

4

1 回答 1

2

我没有对此进行测试,但我认为您可以这样做:

ArrayList all = Settings.AlarmList2;
foreach (ArrayList items in all) {
     // items [0] -> DateTime
     // items [1] -> string1
     // items [2] -> string2
}
于 2009-12-07T03:31:04.857 回答