Hi to all,
I have a question about the delegate
Example
This I think is a correct association of the delegate function.
Somewhere I have seen that is possible to use this sintax
without the "new" statement.
I have tried it and I didn't receive any error or any runtime problem (apparently)
The reason, I think, is that the FunctionUsed matches the delegate structure
What is the difference between these two approach?
Thanks'
Davide
I have a question about the delegate
Example
Code:
public void delegate myDel();
public class myClass
{
...
public myDel d;
}
public class Container
{
List<myClass> lst = new List<myClass>();
void AddFiveValues()
{
for (int i = 0; i < 5; i++)
{
myClass m = new myClass();
m.d = new myDel(FunctionUsed); // <<<===
lst.Add(m);
}
}
void FunctionUsed()
{
...
}
}
Somewhere I have seen that is possible to use this sintax
Code:
m.d = FunctionUsed;
I have tried it and I didn't receive any error or any runtime problem (apparently)
The reason, I think, is that the FunctionUsed matches the delegate structure
What is the difference between these two approach?
Thanks'
Davide