hello.... im sorry for my bad spelling ... i have a problem in saving the result of a metod in a file ... the result is an arraylist ... i dont know how to save it ! in way I save it ,file shows it "system.collection.arraylist" but it must show an array list ...
I hope you can understand what i want!!!

tnx

Try this code,

List<string> a = new List<string>();
a.AddRange(new string[] { "A", "B", "C" });
System.IO.File.WriteAllText("file.txt",string.Join(",", a.ToArray()));

The ArrayList class is also marked as serializeable.

private void Serial()
    {
      ArrayList itemList = new ArrayList();
      itemList.Add("john");
      itemList.Add("smith");
      XmlSerializer serializer = new XmlSerializer(typeof(ArrayList));
      using (FileStream fs = new FileStream(@"C:\fileName.xml", FileMode.Create))
      {
        serializer.Serialize(fs, itemList);
      }
    }

    private void Deserial()
    {
      ArrayList itemList;
      XmlSerializer serializer = new XmlSerializer(typeof(ArrayList));
      using (FileStream fs = new FileStream(@"C:\fileName.xml", FileMode.Open))
      {
        itemList = (ArrayList)serializer.Deserialize(fs);
      }
    }

yw

Please mark this thread as solved if you have found the answer to your original question and good luck!

This question has already been answered. Start a new discussion instead.