Click here to Skip to main content
15,868,016 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Ok, this might be blindingly obvious to most :sigh:

Say I have a thread
Thread myThread;
What is the difference between,
Thread myThread = new Thread(Work.DoWork);
and
Thread myThread = new Thread(new ParameterizedThreadStart(Work.DoWork)); 


MSDN says, C# infers the appropriate delegate creation syntax: new ParameterizedThreadStart(Work.DoWork). So does that mean the above 2 lines are identical?
Posted

1 solution

So does that mean the above 2 lines are identical?


Yes, that's exactly what it means. The verbose version was the only way to do it in C# 1.0, and under the hood it's still what's happening - but since the delegate instantiation is fairly obvious from the context, C# 2 and later don't require you to actually specify it unless there's some sort of ambiguity.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900