如何存儲和恢復3D字符串數組到C#中的文件? 嗨; 我正在編寫一個項目,爲公共數組創建一個類,以便我可以在所有表單中使用它們。如何存儲和恢復3D字符串數組到C#中的文件?
類MainArray
{
// Introduce Moarefi Projeh public static string[] MPArray = new string[15]; // Introduce Moarefi Personel Rozmozd public static string[,] MPRArray = new string[20,15]; // Introduce Moarefi Peymankaran public static string[,] MPeymankaranArray = new string[20, 15]; // Introduce Gozaresh PersonelRozMozd public static string[,] GPRMArray = new string[20, 15]; public static string[,,] MArr = new string[20,20,20];
}
我保存在某些形式的這些陣列的所有數據。我想創建一個類,操作員可以在程序使用結束時將所有這些數組存儲在文件中,並在下次使用該程序時恢復這些數據。
你知道這是我第一次在C#中編程,請給我一個類的代碼,我可以做到這一點。我想要一個類代碼,我在我的主程序中使用一個簡單的鱈魚,如下所示: MyData.WriteArray(MyArrayName,FileName);用於存儲和 MyData.ReadArray(MyArrayName,FileName);恢復。
你想要做的就是所謂的[序列化](http://msdn.microsoft.com/en-us/library/vstudio/ms233843.aspx)。保存文件的格式應該是什麼? Xml還是二進制? – semao
我更喜歡二進制 –