在c#编程中,this 引用类的当前实例的关键字。在C#中,该关键字有三种主要用法。
using System; public class Employee { public int id; public String name; public float salary; public Employee(int id, String name,float salary) { this.id = id; this.name = name; this.salary = salary; } public void display() { Console.WriteLine(id + " " + name+" "+salary); } } class TestEmployee{ public static void Main(string[] args) { Employee e1 = new Employee(101, "Sonoo", 890000f); Employee e2 = new Employee(102, "Mahesh", 490000f); e1.display(); e2.display(); } }
101 Sonoo 890000 102 Mahesh 490000
祝学习愉快!(内容编辑有误?请选中要编辑内容 -> 右键 -> 修改 -> 提交!)