I have this code:
class SomeClass {
void someFunction()
{
Action<string> myAction = (what)=>
{
//whatever
}
new List<string>().ForEach(myAction);
}
}
I'd like to extract the code inside myAction into a separate member function.
How do I do that?
class SomeClass
{
void someFunction()
{
Action<string> myAction = Whatever;
new List<string>().ForEach(myAction);
}
public void Whatever(string what)
{
// ... whenever
}
}
or directly, without defining a local Action<string> variable (that will probably be optimized away in Release mode anyway):
new List<string>().ForEach(Whatever);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With