2009-12-07 12 views
2

Voici le fichier de paramètres qui reste de l'enregistrement. (Enregistrement des propriétés fonctionne correctement.)Charger à partir de 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> 

Comment puis-je charger ce retour dans l'application à l'aide ArrayList? Voici comment je l'ai enregistré.

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

Quelqu'un sait comment je peux l'utiliser pour charger les données à partir des paramètres?

+1

.net 1.1 ou 2.0 ou 3.5? – Fredou

+0

.net 3.5 en utilisant C# – Kevin

Répondre

2

Je n'ai pas testé, mais je pense que vous pouvez faire:

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

Fonctionne! Je vous remercie! – Kevin

Questions connexes