public int CompareTo(object obj) { DataScore d = (DataScore)obj; int cmp = Score.CompareTo(d.Score); if (cmp == 0) { cmp = Time.CompareTo(d.Time); } return(cmp); }
private void CreateDataScore() { if (txtName.Text.Trim() == "") { txtName.Text = "Player"; } DataScore ds = new DataScore(txtName.Text, PlayerData.Score, PlayerData.AllTime); string dir = Directory.GetParent(Directory.GetCurrentDirectory()).Parent.FullName + @"\Data"; string serializationFile = Path.Combine(dir, "scores.bin"); using (Stream stream = File.Open(serializationFile, FileMode.Append)) { var bformatter = new System.Runtime.Serialization.Formatters.Binary.BinaryFormatter(); bformatter.Serialize(stream, ds); } }