0

Porque cuando ingreso un número mayor a 50,000 me muestra "Accepted" y no "Error"?

using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace SoloLearn { class Program { static void Main(string[] args) { int pay = Convert.ToInt32(Console.ReadLine()); Payment pay1 = new Payment(); pay1.PaymentValue = pay; } } class Payment { private int paymentValue; //completa la propiedad public int PaymentValue { get {return paymentValue;} set { if(paymentValue > 50000) Console.WriteLine("Error"); else Console.WriteLine("Accepted"); } } } }

9th Dec 2020, 6:39 PM
Andy Eliu González Pérez
Andy Eliu González Pérez - avatar
1 Respuesta
+ 1
C# uses value as the parameter for the setter. Change if(PaymentValue > 50000) To if(value > 50000)
21st Dec 2020, 6:36 PM
Brian
Brian - avatar
En tendencia hoy
.
1 Votes
What?
0 Votes
HTML
0 Votes
Web
0 Votes
Quiz duel
0 Votes
FRC Coding?
1 Votes
AI
2 Votes
help
0 Votes
APIs
1 Votes