2009-12-07 50 views
2

以下是保存後剩餘的設置文件。 (保存特性正常工作。)從Properties.Settings加載到ArrayList?

<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(); 

任何人都知道我可以使用它來從設置中加載數據?

+1

.NET 1.1或2.0或3.5? – Fredou 2009-12-07 00:51:59

+0

.net 3.5 using C# – Kevin 2009-12-07 00:53:23

回答

2

我沒有測試過這一點,但我認爲你可以這樣做:

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

Works!謝謝! – Kevin 2009-12-07 03:48:54