Home > Net >  C # problem
C # problem

Time:10-03


Public static IEnumerable Select (this IEnumerable The source, Func The selector);
See the night don't understand this code, so why write a.S well (p=& gt; P.N ame), saw the above code I draw a.S elect (a, 1) is wrong, however, have a great spirit to guide it to me? Expanding method, entrust, anonymous methods, lameda expression is understood

CodePudding user response:



//
//abstract:
//encapsulates a method, this method has a parameter, and return by the TResult parameter specifies the type of value, if you want to browse this type..net Framework source code, please refer to the Reference
//Source,
//
//parameters:
//arg:
//the delegate encapsulation method's parameters,
//
//type parameters:
//T:
//the delegate encapsulation method of parameter type,
//
//TResult:
//the delegate encapsulation method return value types,
//
//return the result:
//this entrust encapsulation method return values,
[TypeForwardedFrom (" System. The Core, Version=3.5.0.0, Culture=Neutral, PublicKeyToken=b77a5c561934e089 ")]
Public delegate TResult Func (T arg);

CodePudding user response:

Public static IEnumerable Select (this IEnumerable The source, Func The selector);
First of all, it is an extension,
This IEnumerable Source representative according to the type of extensions, all IEnumerable Type can point to the select method,
Func The selector is a delegate,
So this way, just passed a Func,
The parameters of the front, don't pass

CodePudding user response:

Enumerable Select methods, including TSource is your parameters, TResult is you return values, your understanding is problematic, a.S well (p=& gt; P.N ame) like this is actually the syntactic sugar is Lambda expressions, we said if you really understand the Lambda expressions, actually don't have so many questions,

CodePudding user response:

=& gt; goes to
  •  Tags:  
  • C#
  • Related