Visual Studio Employee类怎么用

这篇文章将为大家详细讲解有关Visual Studio Employee类怎么用,小编觉得挺实用的,因此分享给大家做个参考,希望大家阅读完这篇文章后可以有所收获。

学习Visual Studio时,你可能会遇到Visual Studio Employee类问题,Visual Studio Employee类的派生类型必须具有计算薪水操作,这里将介绍Visual Studio Employee类问题的解决方法,在这里拿出来和大家分享一下。

  • 描述Visual Studio ExchangeRate类

  • 四分钟懂得Visual Studio工具

  • 讨论Visual Studio类设计器多项技巧

  • Visual Studio Shell最新战况

  • 轻松添加Visual Studio类关系图

为Visual Studio Employee类添加一个CalculatePay抽象方法,该方法返回一个十进制数。在Visual Studio Employee类的标题打开其快捷菜单,选择“添加”子菜单和“方法”菜单命令,为新方法命名为“CalculatePay”。在“类详细信息”窗口设置十进制数作为返回类型。该方法应该设置为抽象的。打开CalculatePay方法的快捷菜单并修改“继承修饰符”为abstract(抽象)。然后系统显示一个消息框要求你对这一修改进行确认,选“确定”。

Hourly Employee类应该继承Visual Studio Employee类。这一关系用继承线来创建,具体做法是:将继承线从Hourly Employee类拖到Visual Studio Employee类。

***,为Hourly Employee类添加一个Pay方法。Pay方法只有一个参数,就是工作的小时数。在“类详细信息”窗口,扩展Pay方法的行来打开 “添加参数”项,选择“添加参数”行并输入“Hours”作为参数名,修改类型为十进制数。添加一个HourlyRate属性到该类以使其完整,该属性也是十进制数类型的。

以下代码由类关系图创建。创建的函数是很粗略的,接下来只需要实现这些粗略的函数。

public interface Iemployee  {  int Age  {  get;  set;  }  Name Fullname  {  get;  set;  }  string EmployeeInfo();  }  public struct Name  {  public string FirstName  {  get  {  throw new System.NotImplementedException();  }  set  {  }  }  public string LastName  {  get  {  throw new System.NotImplementedException();  }  set  {  }  }  }  public abstract class Employee : IEmployee  {  #region IEmployee Members  public int Age  {  get  {  throw new Exception(  "The method or operation is not implemented.");  }  set  {  throw new Exception(  "The method or operation is not implemented.");  }  }  public Name Fullname  {  get  {  throw new Exception(  "The method or operation is not implemented.");  }  set  {  throw new Exception(  "The method or operation is not implemented.");  }  }  public string EmployeeInfo()  {  throw new Exception(  "The method or operation is not implemented.");  }  #endregion  public abstract decimal CalculatePay();  }  public class HourlyEmployee : Employee  {  public decimal HourlyRate  {  get  {  throw new System.NotImplementedException();  }  set  {  }  }  public override decimal CalculatePay()  {  throw new Exception(  "The method or operation is not implemented.");  }  public void Pay(decimal Hours)  {  throw new System.NotImplementedException();  }  }

关于“Visual Studio Employee类怎么用”这篇文章就分享到这里了,希望以上内容可以对大家有一定的帮助,使各位可以学到更多知识,如果觉得文章不错,请把它分享出去让更多的人看到。

免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:niceseo99@gmail.com进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。

评论

有免费节点资源,我们会通知你!加入纸飞机订阅群

×
天气预报查看日历分享网页手机扫码留言评论电报频道链接