这和在C#中的功能 [英] this and function in C#
本文介绍了这和在C#中的功能的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
为什么我们在C#plz中使用"this"和"function"关键字告诉我.
why we use "this" and "function" keyword in C# plz tell me.
推荐答案
对于this
,我有一些帮助您: a href ="http://msdn.microsoft.com/en-us/library/dk1507sz.aspx"> http://msdn.microsoft.com/en-us/library/dk1507sz.aspx [ ^ ]
我咨询该网站 C#关键字 <您会发现http://msdn.microsoft.com/zh-CN/library/x53a06bb(v=VS.100).aspx"target =" _ blank"title =" New Window> ^ ]没有您在问题中提出的关键字function
.
问候,
—MRB
Forthis
I have something to help you along: http://msdn.microsoft.com/en-us/library/dk1507sz.aspx[^]
I you consult this site C# Keywords[^] you''ll find that there is no such keywordfunction
as you proposed in your question.
Regards,
—MRB
"this"关键字的用法是:
要限定隐藏有类似名称的成员.
要使对象将自身作为参数传递给其他方法.
要使对象从方法中返回自身.
声明索引器.
声明扩展方法.
在构造函数之间传递参数.
而且在c#中没有功能"关键字.
希望对您有所帮助:)
Uses of "this" keyword are:
To qualify members hidden by similar name.
To have an object pass itself as a parameter to other methods.
To have an object return itself from a method.
To declare indexers.
To declare extension methods.
To pass parameters between constructors.
and there is no "function" keyword in c#.
hope it helps :)
this
:在C#中有几个地方我们使用this
,但是主要的地方是显式地引用其中的类的当前实例.一个方法.这使我们能够区分局部方法参数和类级别实例字段或同名属性:
this
: There are a couple of places we usethis
in C#, but the main one is to explicitly refer to the current instance of the class within a method. THis allows us to distinguish between a local method paramter and an class level instance feild or property of the same name:
private string myValue;
void MyMethod(string myValue)
{
this.myValue = myValue; //Assigns the value in the method parameter to the class level field.
}
在this
关键字上查看MSDN-它会解释更多. http://msdn.microsoft.com/en-us/library/dk1507sz (v = vs.71).aspx [ http://msdn.microsoft.com/zh-CN -us/library/x53a06bb(v = vs.71).aspx [
Have a look at MSDN on the this
keyword - it explains more. http://msdn.microsoft.com/en-us/library/dk1507sz(v=vs.71).aspx[^]
function
: We don''t - it isn''t a keyword. See MSDN list of keywords: http://msdn.microsoft.com/en-us/library/x53a06bb(v=vs.71).aspx[^]
这篇关于这和在C#中的功能的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文