public static Lotto LoadData(string filePath) { Stream stream = null; Lotto lotto = null; try { stream = File.OpenRead(filePath); BinaryFormatter serializer = new BinaryFormatter(); lotto = (Lotto)serializer.Deserialize(stream); } catch { } finally { stream.Dispose(); } return(lotto); }
public static bool SaveData(Lotto _lotto, string fileName) { var res = true; Stream stream = null; try { stream = File.Create(fileName); var serializer = new BinaryFormatter(); serializer.Serialize(stream, _lotto); } catch { res = false; } finally { stream?.Dispose(); } return(res); }
static void LoadData(Lotto _lotto) { _lotto.AddDraw(new Draw(1, new DateTime(2017, 10, 13, 23, 0, 0), new int[] { 21, 15, 12, 3, 44, 2 }, 25279082, true)); }