using System; using System.Xml; using System.Collections.Generic; using System.Linq; using System.Text; namespace ConsoleApplication1 { class Program { static void Main(string[] args) { SortedSet PlayerList = new SortedSet(); while (true) { string Input; Console.WriteLine("What would you like to do?"); Console.WriteLine("1. Create new player and score."); Console.WriteLine("2. Display Highscores."); Console.WriteLine("3. Write out to XML file."); Console.Write("Input Number: "); Input = Console.ReadLine(); if (Input == "1") { Player player = new Player(); string PlayerName; string Score; Console.WriteLine(); Console.WriteLine("-=CREATE NEW PLAYER=-"); Console.Write("Player name: "); PlayerName = Console.ReadLine(); Console.Write("Player score: "); Score = Console.ReadLine(); player.Name = PlayerName; player.Score = Convert.ToInt32(Score); //==================================== //ERROR OCCURS HERE //==================================== PlayerList.Add(player); Console.WriteLine("Player \"" + player.Name + "\" with the score of \"" + player.Score + "\" has been created successfully!" ); Console.WriteLine(); } else { Console.WriteLine("INVALID INPUT"); } } } } }
So i keep getting the "
At least one object must implement IComparable.
" when trying to add a second player, the first one works, but the second one doesn't. I also MUST use SortedSet
because that is the requirement for the work, it's school work.