I expect this to sound like an obvious question but, does the delegate return type have to match the return type of the method it is delegating too?
EG, like this:
public static void Save()
{
TS ts = new TS(SaveToDatabase);
}
public delegate void TS();
private static void SaveToDatabase()
{ }
where this will never work
public static void Save()
{
TS ts = new TS(SaveToDatabase);
}
public delegate string TS();
private static void SaveToDatabase()
{ }
Yes, It has to return the same type and have the same parameters.
In other words, the function and the delegate declaration must have the same signature.
Example:
EDIT:
If you see the sample code, Squared Delegate and ValueTimesValue function have the same return type and parameters.