Suppose I have some delegate in C#:
public delegate void ExampleDelegate();
and somewhere I have SampleMethod which I want the delegate to reference:
ExampleDelegate sample = new ExampleDelegate(SampleMethod);
What I've seen some people do in 2 lines instead is this:
ExampleDelegate sample;
sample = SampleMethod;
Is this the same like the line above in terms of functionality or is there some (unintended) side effect going on? Basically, I don't understand the difference between:
ExampleDelegate sample = new ExampleDelegate(SampleMethod);
and
ExampleDelegate sample; = SampleMethod;
They seem to be working the same..