Question

I have Visual Studio 2012 and have my target framework set to .NET 2.0.

But I have:

ThreadPool.QueueUserWorkItem(example => Threadedmethod(intval,classVal) );

void Threadedmethod(int id, MyClass val)
{ ....  }

and it compiles.

How can I tell if this will work from VS2012? I have been told the => operator is not compatible with .NET 2.0.

Was it helpful?

Solution

I think you're confused with .net version and c# version. When you target to .Net 2.0, you can still use c#(language features) like lambda, extension methods, collection initializer, object initializer etc.

This has nothing to do with the .Net version. Thing is you can't use classes which are newly added in .Net version > your target version.

Keep in mind that when it gets compiled your code is perfectly valid and it will run properly in machine with only .Net framework 2.0.

I have been told => is not valid in .net 2.0

It is wrong, correct statement would be is not valid in c# 2.0 but you're not using c# 2.0 in VS2012. It is c# 5.0 compiler you use there.

For more information read Jon's article especially Using C# 3 in .NET 2.0 and 3.0 part.

My conclusion: Your application will work perfectly in .Net 2.0 without any doubt.

OTHER TIPS

as I have been told => is not valid in .net 2.0

This is not true. You can run .Net 2.0 framework on VS2012.

Check this wiki which lists all the framework which are allowed in VS2012.

Visual Studio 2012 Dev11 11.0 2.0, 3.0, 3.5, 4.0, 4.5 02012-09-12September 12, 2012

From the MSDN:

Framework targeting does not guarantee that your application will run correctly. You must test your application to make sure it runs against the targeted version. You cannot target framework versions that are earlier than the .NET Framework 2.0.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top