Possible to change method called inside foreach?
I have a created a function as below
public static ICustomers[]? SanitiseCustomers(this string[]? custVals, float boxed = 0.5f)
{
List<ICustomers> customers = [];
foreach (var c in custVals)
{
customers.Add(c.Sanitize(boxed));
}
return [.. customers];
}
I want to replace the Sanitize function within the foreach loop to a different method.
I dont want to copy and paste the function and create a new one and changing Sanitize to FriendlyBox but trying to see if there is a way to switch the method name depending on the way this function is called?
I have a created a function as below public static ICustomers[]? SanitiseCustomers(this string[]? custVals, float boxed = 0.5f)
{
List<ICustomers> customers = [];
foreach (var c in custVals)
{
customers.Add(c.Sanitize(boxed));
}
return [.. customers];
} I want to replace the Sanitize function within the foreach loop to a different method. I dont want to copy and paste the function and create a new one and changing Sanitize to FriendlyBox but trying to see if there is a way to switch the method name depending on the way this function is called? Read More