How do you reference the chained method’s object in that same method’s arguments. Let’s say you have a number of chained method calls that trim/substring a string like so:
str.Substring(varLen1).Substring(varLen2).Substring(1,##self##.Length-2)
The problem is that because the length of the string is now unknown and different from the original string’s length, how do I substring like in the last call (a substring where the index and length may depend on the string itself).
Thanks!
In short, no.
Though with an extension method you could capture
##self##and use a lambda to continue the expression.I tend to think that ends up more complicated to read and uglier and simply prefer to create a separate function.