What is the difference between
Thread t = new Thread (new ThreadStart (Go));
and
Thread t = new Thread (Go);
where Go is a method
The only time there is a difference is if Go is a method-group that could match multiple Thread constructor overloads - for example, because there is a constructor for both ThreadStart and ParameterizedThreadStart, the following methods would make the new Thread(Go) version ambiguous:
static void Go() { }
static void Go(object val) { }
The new Thread (new ThreadStart (Go)) disambiguates that by explicitly declaring the delegate type, but: other than that they are identical, on C# 2 or above. Note: prior to C# 2, the shorter version was not legal syntax.
None. They are the same thing.
The documentation states this:
Visual Basic and C# users can omit the
ThreadStartorParameterizedThreadStartdelegate constructor when creating a thread. [...] In C#, simply specify the name of the thread procedure. The compiler selects the correct delegate constructor.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With