This is a Follow-up to Simple pay rate calculatorHere is what I came up with.  Hopefully if I have missed something that was said in answers on the previous question, we can still get those things pointed out.  I am hoping that I made the code cleaner.Main Methodclass MainClass{    public static void Main (string[] args)    {         //var payCheck = new PayRateCalculator(Hart,40,23);        var payCheck = new PayCalculator();        Console.Write (Please provide the Employees Last Name >>);        payCheck.lastName = Console.ReadLine();        Console.Write (How many hours has employee {0} worked? >>, payCheck.lastName);        payCheck.hours = Convert.ToInt32 (Console.ReadLine());        Console.Write (What is employee {0}'s hourly wage? >>, payCheck.lastName);        payCheck.payrate = Convert.ToInt32 (Console.ReadLine ());        Console.WriteLine ({0}'s Gross pay is ${1}, payCheck.lastName, payCheck.GrossTotal());        Console.WriteLine ({0}'s Net pay is ${1}, payCheck.lastName, payCheck.NetTotal());    }}PayCalculator Classclass PayCalculator{    private const decimal _PayRateDefault = 8.25m;    private decimal _payrate = _PayRateDefault;    private decimal _withholdingRate = 0.20m;    private decimal _hours;    public decimal hours {         get {            if (hours < 1) {                return 40;            } else {                return _hours;            }        }        set {            _hours = value;        }    }    public decimal grossPay { get;set; }    public decimal netPay { get; private set; }    public decimal payrate {        get {            return _payrate;        }        set {            if (value < 8.25){                _payrate = 8.25m;            } else {                _payrate = value;            }        }    }    public decimal WithholdingRate{ get; set; }    public string lastName { get; set; }    public decimal GrossTotal ()    {        grossPay = hours * payrate;        return grossPay;    }    public decimal NetTotal ()    {        grossPay = GrossTotal();        netPay = grossPay - (grossPay * _withholdingRate);        return netPay;    }    public PayCalculator (string lastName, decimal hours, decimal payRate)    {        this.hours = hours;        this.payrate = payrate;        this.lastName = lastName;    }    public PayCalculator ()    {    }}I am going to put the beginner tag on this again because I know that my coding skills are still not very good.   This will be the last review for this little bit of code.  I am going to see what else catches my eye in this book while I am working through it.
Follow up to Pay Rate Calculator
c#;beginner
There are several things to address here:Naming Conventions: only fields, method parameters, and local variables should be camelCase, everything else should be PascalCase. This doesn't make your programs run better, but it does make you a more likable programmer in the workplace. Being able to produce code that is consistent with your co-workers will help you stay employeed. No one likes a rogue programmer.Validate all external input: in your application the external input is coming from the info provide by the user of your program. It could be a text box in a windows application or data provided to a web service that you have written. In all cases you need to validate the input before processing so that you can provide the user with an appropriate message. In your case there are places where valid values cannot be less than zero. Check for that and alert the user of their mistake. Here is an example that verifies the pay rate and ensures that it is at least the minimum pay rate.decimal GetRate(string lastName){    decimal rate = -1m;    string tmp = string.Empty;    do    {        Console.Write(What is employee {0}'s hourly wage? >>, lastName);        tmp = Console.ReadLine();        if (!decimal.TryParse(tmp, out rate) || rate < Paycheck.MinimumHourlyRate)        {            Console.WriteLine(hourly wages must be a valid number greater than {0:#######.00}, Paycheck.MinimumHourlyRate);            rate = -1m; // set the rate to an out of bounds value because the TryParse call may have returned false        }    } while (rate < Paycheck.MinimumHourlyRate);    return rate;}Do not let objects be created in an invalid state: This is not always possible to achieve, but you have total control over this code. Your PayCalculator class has computed values for both gross and net pay. Neither of these values make sense with out an appropriate pay rate and number of hours. Therefore all constructors should take, at a minimum, these two values. This ensures that your PayCalculator does not get created in an invalid state.Do not let objects become invalid: You should be checking that values are in range when being assigned. This is different than the validation mentioned earlier. For example negative hours make no sense in this program. You should throw an appropriate exception if someone tries to set the number of hours worked to a negative value:decimal _numberOfHours;public decimal NumberOfHours{    get    {        return _numberOfHours;    }    set    {        if (value < 0)            throw new ArgumentOutOfRangeException(NumberOfHours, value, value cannot be less than zero);    }}If you perform proper validation as discussed earlier, this exception should never be thrown. However, the whole point of exceptions is for exceptional situations that are not supposed to occur.Principle of least astonishment: You have places in your code that assume a default value when the supplied value is out of range. For example, in the property setter of payrate:if (value < 8.25)  _payrate = 8.25m;A user of your code that tries to assign 1.0m to the payrate property is not expecting that value to magically change to 8.25m. If you refer back to the example for the NumberOfHours property you will see that I am not defaulting a negative value to zero. I am throwing an exception. It is the user's responsibility to provide your PayCalculator class with valid values. In order to facilitate this you should be documenting your code. The NumberOfHours example property should clearly document that it will throw an exception if someone tries to assign a negative value to that property.ConclusionThe items explained above should be carried beyond this program and taken into consideration for all programs that you write. They will make you a better programmer in the long run if you adopt them now.There are also a few other things in your code that are incorrect. Those are simply bugs in your codeWithholdingRate does not use its backing fieldYou are using Convert.ToInt32 for a decimal valueusing Convert.ToInt32 or the correct Convert.ToDecimal function can throw exceptions if text is entered. You should code for that. I recommend using decimal.TryParse instead.the payrate property setter checks value < 8.25, 8.25 is going to be a double. double values can lose precision. It won't lose precision in the case of 8.25 but you should be doing 8.25m so that this problem does not arise