❔ What is happening under the covers to allow this to work
someRandomString.Split('.').Select(HttpUtility.HtmlDecode);
From the definition of HtmlDecode, it has an anonymous constructor, and one which takes a 's' parameter for the string. How on earth is this linq working that it can somehow construct it and pass the string in and get the result?6 Replies
is the same as
HtmlDecode doesn't have a constructor 😐
it's a method
sorry yea a method, said that wrong
does it just insert it into the first method that has a single string param?
Linq's
.Select()
is defined something like Select<TIn, TOut>(Func<TIn, TOut> func)
So any method or function that takes a TIn
and returns a TOut
will fit
(string s) => DoStuffWithString(s)
fits the bill, but so does DoStuffWithString()
itselfthat is pretty wild, I was wondering wtf was going on
thank you
Was this issue resolved? If so, run
/close
- otherwise I will mark this as stale and this post will be archived until there is new activity.