语法

实现属性
public string MyText
{
    get {return mText;}  //不创建 get 为只读
    set {mText = value;} //不创建 set 为只写
}

索引
public int this[int index]
{
    get {return IntArray[index];}
    set {IntArray[index] = value;}
}

强类型集合属性
private ArrayList mWidgets = new ArrayList();
public Widget GetWidget(int I)
{
    return (Widget)mWidgets[I];
}
public void SetWidget(int I,Widget Wid)
{
    mWidgets.Insert(I,Wid);
}

委托
一个类型安全的函数指针,可以用来调用方法。
public delegate int myDelegate(double D);

事件
public delegate void aDelegate(double d);
public event aDelegate aEvent;

引发事件
aEvent(666);

激活事件
public event EventHandler Changed;
protected void OnChanged()
{
    if (Changed == null)return;
    Changed(this,System.EventArgs.Empty);
}

事件处理程序
Account.aEvent += new aDelegate(aEventFun); //可关联多个事件

例 button1.Click += new System.EventHandler(clickHandler);

运行时移除事件
Account.aEvent -= new aDelegate(aEventFun);

定义别名
using Diag = System.Dragnstics;

using范围
using (FormAbout form = new FormAbout())
{
  form.ShowDialog();
}
对象需实现IDieposable接口
代码块结束时调用Dispose方法

 

转载于:https://www.cnblogs.com/zuopyu/archive/2005/08/20/219307.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值