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

tnx

yw

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

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.