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 Odpowiedź
+ 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