c# - 我无法显示代码的输出
问题描述
创建一个名为 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++ - 使用 Visual Studio 的 x86 程序集错误
- keycloak - Keycloak 领域设置不再显示“重复电子邮件”开关
- elasticsearch - Elasticsearch helm chart 给出 AccessDenied 异常
- html - 如何集中两个图像并在它们之间添加一些文本
- javascript - 使用 useState Hook 在 React 中渲染字符串数组
- jsf - 无法在 JSF 页面中显示数据库中的数据
- c# - 在 UWP 应用程序的完全信任 win32 组件中使用 .NET 标准库时引发 FileNotFoundException(无法加载文件或程序集)
- xml - 读取XML文件中提到的垃圾值如何报错?
- sql - Sql Query 转换为打开 qnt 的 sql 表。购买 qnt,并关闭 qnt
- javascript - jQuery 每个方法都不会选择附加的 HTML