zoukankan      html  css  js  c++  java
  • C#中简单的this与get的用法(string,decimal)

    代码
    namespace First
    {
    publicpartialclass Form1 : Form
    {
    public Form1()
    {
    InitializeComponent();
    }

    privatevoid Form1_Load(object sender, EventArgs e)
    {
    Employee E1
    =new Employee("xiaohong","you");
    E1.Salary
    =4.2m;
    E1.printEmployee();
    this.Close();
    }

    privatevoid button1_Click(object sender, EventArgs e)
    {
    MessageBox.Show(
    "Hi");
    this.Close();
    }
    }
    class Employee
    {
    privatestring name;
    privatestring alias;
    privatedecimal salary;
    public Employee(string name, string alias)
    {
    this.name = name;
    this.alias = alias;
    }
    publicdecimal Salary
    {
    get
    {
    return salary;
    }
    set
    {
    salary
    = value;
    }
    }

    publicvoid printEmployee()
    {
    MessageBox.Show(
    "Name:"+ name +" "+"Alias:"+ alias +" "+"num:"+ salary);
    // MessageBox.Show( Employee.SalcTax(this));

    }
    }
    }

    代码
    namespace First
    {
    publicpartialclass Form1 : Form
    {
    public Form1()
    {
    InitializeComponent();
    }

    privatevoid Form1_Load(object sender, EventArgs e)
    {
    Employee E1
    =new Employee("xiaohong","you");
    E1.Salary
    =1.10m;
    E1.printEmployee();
    this.Close();
    }
    }
    class Employee
    {
    privatestring name;
    privatestring alias;
    privatedecimal salary;
    public Employee(string e, string s)
    {
    this.name = e;
    this.alias = s;
    }
    publicdecimal Salary
    {
    get
    {
    return salary;
    }
    set
    {
    salary
    = value;
    }
    }
    publicstaticdecimal SalcTax(Employee E)
    {
    return3* E.Salary;
    }
    publicvoid printEmployee()
    {
    MessageBox.Show(
    "Name:"+ name +" "+"Alias:"+ alias +" "+"Salary"+ Employee.SalcTax(this));
    // MessageBox.Show( Employee.SalcTax(this));

    }
    }
    }

  • 相关阅读:
    使用阿里云服务器的总结二-----目录权限
    使用阿里云服务器的总结一----修改配置
    thinkphp框架开启页面gzip压缩
    内容页分页代码
    js禁止中文输入 最简洁的【禁止输入中文】
    JS中setTimeout()的用法详解
    面向对象的5条基本设计原则
    C#_面试题1
    问题 E: C语言11.8
    问题 D: C语言11.7
  • 原文地址:https://www.cnblogs.com/wwwzzg168/p/3570079.html
Copyright © 2011-2022 走看看