I saw that the delegate is used for custom events. as an example
delegate string FuncRef(string Val); FuncRef fValue = GetFieldName; fValue("hello");
what I am here is simply declaring a delegate and assigning a function name for delegation and calling fValue("hello"); whenever required.
instead of calling GetFieldName() via a delegate, I can call it directly. so I just want to know why I should use a delegate to call a function, where we can directly call a function ... what is the advantage of calling any function through a delegate.
please tell me in which scenario the use of a delegate is required other than event handling. please help me with a code sample and simulate a situation when I need to call a function through a delegate, in addition to handling events. please show me some real life scenario where we have to call a function through a delegate.
c # delegates
Mou
source share