[Solved] Saving values from arraylist to txt C# [closed]


    static void SaveArray()
    {
        ArrayList myArray = new ArrayList();
        myArray.Add("First");
        myArray.Add("Second");
        myArray.Add("Third");
        myArray.Add("and more");

        StreamWriter sw= File.CreateText(@"C:\file.txt");
        foreach (string item in myArray)
        {
            sw.WriteLine(item);
        }
        sw.Close();
    }

and you shouldn’t use arraylist not because its 2013 ,but because arraylist boxing each item in the array, where List store the type also.

this cost less in memory use.

3

solved Saving values from arraylist to txt C# [closed]