C# delegate: literal constructor -
this question has answer here:
suppose have delegate in c#:
public delegate void exampledelegate();
and somewhere have samplemethod want delegate reference:
exampledelegate sample = new exampledelegate(samplemethod);
what i've seen people in 2 lines instead this:
exampledelegate sample; sample = samplemethod;
is same line above in terms of functionality or there (unintended) side effect going on? basically, don't understand difference between:
exampledelegate sample = new exampledelegate(samplemethod);
and
exampledelegate sample; = samplemethod;
they seem working same..
there no difference, same. second implicit method group conversion.
this syntax introduced in c# 2.0 , covered in programming guide in how to: declare, instantiate, , use delegate.
Comments
Post a Comment