开发者

This keyword in C#, Linq?

What's the meaning of this usage of the this keyword开发者_运维百科 in C#:

public static ExcelRow Hide(this ExcelRow row)
  {
   return row.Hide(true);
  }

Is this Linq ? If yes, what's the difference between ExcelRow row and this ExcelRow row ?

Note: It's not a spelling bug, there's no point or other accessor in between.


In this particular context it denotes that the Hide method is an Extension Method that can be called on instances of the ExcelRow type.


It means that it is an extension method. This refers to the instance of ExcelRow for which the method is invoked.


The method you have above is an extension method (msdn.microsoft.com/en-us/library/bb383977.aspx). The "this ExcelRow row" part of the signature means that the method extends an excelRow object. So you can use it on an instance of ExcelRow. Eg: ExcelRow row = new ExcelRow(); row.Hide(); The ExcelRow part of the definition (after the static keyword) simply means that your extension method returns an instance of the ExcelRow Type

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜