The hidden methods in delegation are somewhat confusing. Please give instructions by experts.
The three paragraphs belowCodeWhat is the difference between code1, code2, and code3? It is best to give a detailed description.
Code1:
Using system; namespace consoleapplication1 {class program {delegate string delegatetest (string Val); static void main (string [] ARGs) {string mid = ", middle part ,"; delegatetest anondel = delegate (string PARAM) {Param + = mid; Param + = "and this is added to the string. "; return Param ;}; console. writeline (anondel ("Start of string "));}}}
Code2:
Using system; namespace consoleapplication1 {class program {delegate string delegatetest (string Val); static string mid = ", middle part,"; static void main (string [] ARGs) {delegatetest anondel = new delegatetest (delmethod); console. writeline (anondel ("Start of string");} static string delmethod (string PARAM) {Param + = mid; Param + = "and this is added to the string. "; return Param ;}}}
Code3:
Using system; namespace consoleapplication1 {class program {delegate string delegatetest (string Val); static void main (string [] ARGs) {string mid = ", middle part ,"; delegatetest anondel = new delegatetest (delegate (string PARAM) {Param + = mid; Param + = "and this is added to the string. "; return Param;}); console. writeline (anondel ("Start of string "));}}}
I just learned about delegation. I will answer O (∩ _ ∩) O Haha ~
Code1 and code3 should both be anonymous, and code2 should be standard. Code1 and code3 are only issues in writing.