I have a function which takes a custom delegate as parameter in order to achieve the following:
delegate T TryParseDelegate<I,O,T>(I input, O output);
private string[] ReadMultiStringValue (string propertyName, TryParseDelegate<string, string[], bool> tryParse)
{
string cellValue = GetCellValue(propertyName);
string[] values = null;
if (tryParse(cellValue, values))
return values;
else
throw new Exception("Invalid cell value");
}
Which I would call like so:
string[] parsedValue = ReadMultiStringValue("myProperty", (n,p) => ParseHelper.TryParseName(n, out p));
When I debug the code, everything seems to work properly, except "values" remains null after going through tryParse (and yet is updated correctly when inside the TryParseName method). I tried adding the out keyword to values, but I get the error "Argument 2 may not be passed with the out keyword".
What am I missing here?