0

Ayúdenme a sobrecargar el operador con operator+

using System; using System.Collections.Generic; namespace Code_Coach_Challenge { class Program { 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); } } class DancerPoints { public string name; public int points; public DancerPoints(string name, int points) { this.name = name; this.points = points; } //sobrecarga el operador + } }

18th Apr 2021, 4:06 PM
Leonardo Rodríguez
Leonardo Rodríguez - avatar
1 Respuesta
+ 1
public static Box operator+(Dancer a, Dancer b) { string name = a.name + b.name; int Points = a.points + b.points; Dancer res = new Dancer(name, Points); return res; }
29th Apr 2021, 1:12 AM
Benjamin Salas
Benjamin Salas - avatar