VB.net 2010 视频教程 VB.net 2010 视频教程 python基础视频教程
SQL Server 2008 视频教程 c#入门经典教程 Visual Basic从门到精通视频教程
当前位置:
首页 > temp > C#教程 >
  • C# 类的成员

1.C# 类成员:构造函数、析构函数

构造函数分为: 实例构造器 和 类型构造器

 

2.C# 类成员:常量、字段

 

3. C# 类成员:属性、索引器

 

4. C# 类成员:方法、事件

 

5. C# 类成员:运算符重载

 

6. C# 类成员:嵌套类

 

复制代码
 1 using System;
 2 
 3 intelnal sealed class Test{
 4 
 5     //构造函数
 6     public Test(){}
 7 
 8     //析构函数
 9     ~Test(){}
10     
11     //常量
12     const int x = 123;
13     
14     //字段
15     public string _aProp;
16 
17     //属性
18     public string AProp{get; set;}
19     
20     //索引器
21     public string this[int i]{
22         get{ return null; }
23         set{}
24     }
25     
26     //方法
27     public void AFunc(string arg){}
28 
29     //事件
30     event EventHandel AnEvent;
31 
32     //操作符重载
33     public static bool operator ==(Test t1, Test t2){
34         return true;
35     }
36 
37     //嵌套类
38     class Nested{
39         Nested() { }
40     }
41 }
复制代码

 出处:https://www.cnblogs.com/ihanww/p/csharp_class_member.html


相关教程