首页 > 解决方案 > 我无法显示代码的输出

问题描述

创建一个名为 Employee 的类,其中包括三个信息作为实例变量或自动实现的属性——名字(字符串类型)、姓氏(字符串类型)和月薪(十进制)。您的类应该有一个初始化这三个值的构造函数。为任何实例变量提供带有 get 和 set 块的属性。如果月薪是负数,set 块应该保持实例变量不变。为 Employee 编写一个测试驱动程序,演示 Employee 类的功能(为此使用 Program.cs)。创建 3 个 Employee 对象并显示每个对象的年薪。然后给每个 Employee 加薪 10% 并再次显示每个 Employee 的年薪。

这是我到目前为止所做的:第 1 部分

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace EmployeeDB
{
    class Employee
    {
        public string FirstName { get; set; }
        public string LastName { get; set; }
        private decimal salary;

        //constructor
        public Employee[string firstName string lastName decimal salary]
        {
            FirstName = firstName;
            LastName  = lastName;
            Salary = salary

        }  
        public decimal Salary
        {
            get { return salary; }
            set
            {
                if (value >= 0)
                    salary = value;
            }
        }   
    }    

标签: c#

解决方案


推荐阅读