[英]Object Sender and EventArgs
Consider this function signature: 考虑这个函数签名:
Private Void TextBox1_TextChange(Object Sender, EventArgs e)
As far as my knowledge goes I understand it as below. 据我所知,我理解如下。
Private is a modifier Private是一个修饰符
Void is the return type Void是返回类型
TextBox1_TextChange
is an event name. TextBox1_TextChange
是一个事件名称。
Maybe I am wrong in the above case as I just started practicing in C#, Visual Studio 2005. 也许我在上面的例子中错了,因为我刚刚开始在C#,Visual Studio 2005中练习。
What is the definition/meaning of (Object Sender, EventArgs e)
and how does it work? (Object Sender, EventArgs e)
的定义/含义是什么?它是如何工作的?
TextChange
is (probably) the name of the relevant event, though the event isn't shown in your code snippet so I can't be sure. TextChange
(可能)是相关事件的名称,虽然事件没有显示在您的代码段中,所以我无法确定。
TextBox1_TextChange
is the name of a method that is probably set up to handle an event. TextBox1_TextChange
是可能设置为处理事件的方法的名称。
Object Sender
is a parameter called Sender
that contains a reference to the control/object that raised the event. Object Sender
是一个名为Sender
的参数,它包含对引发事件的控件/对象的引用。
EventArgs e
is a parameter called e
that contains the event data, see the EventArgs MSDN page for more information. EventArgs e
是一个名为e
的参数,包含事件数据,有关详细信息,请参阅EventArgs MSDN页面。
See this page, Passing Parameters , for more information about how parameters work. 有关参数如何工作的详细信息,请参阅此页面“ 传递参数” 。
And this page, Events Tutorial , would probably be helpful as well. 而这个页面, 事件教程 ,也可能会有所帮助。
Object Sender: which object is invoked the current event.in your case TextBox1 is sender. 对象发件人:调用当前事件的对象。在您的情况下,TextBox1是发件人。 EventArgs e :e is the object for EventArgs, when TextChange is invoked object e contain arguments. EventArgs e:e是EventArgs的对象,当调用TextChange时,对象e包含参数。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.