//overload the + operator public static DancerPoints operator+(DancerPoints a, DancerPoints b) { string name = a.name + " & " + b.name; int points = a.points + b.points; DancerPoints res = new DancerPoints(name, points); return(res); }
static void Main(string[] args) { string name1 = Console.ReadLine(); int points1 = Convert.ToInt32(Console.ReadLine()); string name2 = Console.ReadLine(); int points2 = Convert.ToInt32(Console.ReadLine()); DancerPoints dancer1 = new DancerPoints(name1, points1); DancerPoints dancer2 = new DancerPoints(name2, points2); DancerPoints total = dancer1 + dancer2; Console.WriteLine(total.name); Console.WriteLine(total.points); }