Visual C++ 2005 系列课程学习笔记-5
2008-09-04 03:30
531 查看
Visual C++ 2005与Visual C#的对比(Visual C++2005中的组件成员)
Visual C++ 2005:
Ref class MyClass
{
private:
int x;
public:
property int X //组件成员:属性
{
int get()
{
return x;
}
void set(int value)
{
x = value;
}
}
};
public delegate void EventHandler(Object^ sender,EventArgs^ e) //委托
ref class button
{
public:
event EventHandler^ Click; //组件成员:事件
}
public ref class Form1
{
Button^ Button1;
void Button1_Click(Object^ sender,EventArgs^ e)
{
////////////////
}
public:
Form1()
{
Button1 = gcnew Button;
Button1->Click += gcnew EventHandler(this,&Button1_Click); //组件成员:使用事件
}
}
Visual C#:
class MyClass
{
private int x;
public int X // 属性
{
get
{
return x;
}
set
{
x = value;
}
}
};
public delegate void EventHandler(Object sender,EventArgs e) //委托
class button
{
public event EventHandler Click; //事件
}
public class Form1
{
Button Button1;
void Button1_Click(Object sender,EventArgs e)
{
////////////////
}
Form1()
{
Button1 = new Button();
Button1.Click += new EventHandler(Button1_Click); //使用事件
}
}
Visual C++ 2005:
Ref class MyClass
{
private:
int x;
public:
property int X //组件成员:属性
{
int get()
{
return x;
}
void set(int value)
{
x = value;
}
}
};
public delegate void EventHandler(Object^ sender,EventArgs^ e) //委托
ref class button
{
public:
event EventHandler^ Click; //组件成员:事件
}
public ref class Form1
{
Button^ Button1;
void Button1_Click(Object^ sender,EventArgs^ e)
{
////////////////
}
public:
Form1()
{
Button1 = gcnew Button;
Button1->Click += gcnew EventHandler(this,&Button1_Click); //组件成员:使用事件
}
}
Visual C#:
class MyClass
{
private int x;
public int X // 属性
{
get
{
return x;
}
set
{
x = value;
}
}
};
public delegate void EventHandler(Object sender,EventArgs e) //委托
class button
{
public event EventHandler Click; //事件
}
public class Form1
{
Button Button1;
void Button1_Click(Object sender,EventArgs e)
{
////////////////
}
Form1()
{
Button1 = new Button();
Button1.Click += new EventHandler(Button1_Click); //使用事件
}
}
相关文章推荐
- Visual C++ 2005 系列课程学习笔记-8
- Visual C++ 2005 系列课程学习笔记-9
- Visual C++ 2005 系列课程学习笔记-1
- Visual C++ 2005 系列课程学习笔记-2
- Visual C++ 2005 系列课程学习笔记-3
- Visual C++ 2005 系列课程学习笔记-4
- Visual C++ 2005 系列课程学习笔记-6
- Visual C++ 2005 系列课程学习笔记-7
- sql server 2005下载|学习|教程|笔记系列文章
- Andrew NG机器学习课程笔记系列之——机器学习之神经网络模型-下(Neural Networks: Representation)
- NodeJS学习系列课程笔记(NodeJs 快速上手+用法示例)
- NodeJS学习系列课程笔记(NodeJs REPL相关使用方法)
- 【学习】构建WCF面向服务的应用程序系列课程笔记:(1) WCF概要
- AI角 | 把吴恩达深度学习系列课程画出来,这有份诚意满满的笔记求查收
- SQL Server 2005盛宴系列之一:SQL Server 2005产品简介-----学习笔记
- 1自定义View系列课程学习笔记——之手势处理
- SQL Server 2005 学习笔记系列文章导航
- NodeJS学习系列课程笔记(NodeJs Stream 的相关使用方法)
- NodeJS学习系列课程笔记(NodeJs EventEmitter相关使用方法)
- 3自定义View系列课程学习笔记——之Measure测量