<p>Are there any advantages compiling for .NET Framework 3.5 instead of 2.0?</p>
<p>For example less memory consumption, faster startup, better performance...</p>
<p>Personally I don't think so however, I may have missed something.</p>
<h2>Edits</h2>
<ol>
<li><p>Of course there are more features in the 3.5 framework, but these are not the focus of this question.</p>
</li>
<li><p>There seem to be no advantages.</p>
</li>
<li><p>Yes I meant targeting the Framework. I have installed the latest 3.5 SP1 and VS 2008 so what's the difference between compiling with and targeting a framework? I can target the framework in the project options but how do I 'compile with' a specific framework version? I did not know that there is a difference.</p>
</li>
<li><p>So for now we agree that there are no advantages.</p>
</li>
</ol>

[{'answer_id': 66788, 'author': 'Patrick', 'author_id': 429, 'author_profile': 'https://Stackoverflow.com/users/429', 'pm_score': 0, 'selected': False, 'text': "<p>3.5 has classes that 2.0 doesn't. Func&lt;...> for instance. If you aim for 2.0, you can't use them. </p>\n"}, {'answer_id': 66796, 'author': 'Sklivvz', 'author_id': 7028, 'author_profile': 'https://Stackoverflow.com/users/7028', 'pm_score': 1, 'selected': False, 'text': "<p>I haven't found any. An obvious <em>disadvantage</em>, if you don't need the 3.5 specific features, is that the 3.5 code base is younger and is therefore possible, albeit unlikely, that there is some bug lurking around.</p>\n"}, {'answer_id': 66816, 'author': 'Jorge Córdoba', 'author_id': 2695, 'author_profile': 'https://Stackoverflow.com/users/2695', 'pm_score': 4, 'selected': True, 'text': '<p>There\'s a difference between compiling and targeting.</p>\n\n<p>Compiling the code with the (for example) C# 3.0 compiler will probably give you a boost on performance (very little one anyway) as some optimization for the generated IL code migh have been included. It also allows you to use some of the new features like automatic properties or lambda expressions.</p>\n\n<p>Targeting for a given framework will ensure your assembly works for that framework (and posteriors) and will fail if you target for 2.0 and are using a 3.5 library. No performance improvements will be directly related to that unless your substituting a class from one framework with another "fastest" class. For example, targeting .NET 1.1 won\'t allow you to use generics and therefore you\'ll have to use the ArrayList which is considerably slower than List (due to boxing and unboxing).</p>\n'}, {'answer_id': 67153, 'author': 'Chris Pietschmann', 'author_id': 7831, 'author_profile': 'https://Stackoverflow.com/users/7831', 'pm_score': 2, 'selected': False, 'text': '<p>There are two things to remember in regards to .NET 2.0 and .NET 3.5.</p>\n\n<ol>\n<li>The .NET Framework 3.5 is just a few libraries that run on top of .NET 2.0.</li>\n<li>When developing in Visual Studio 2008 and targeting .NET 2.0 you can still use certain C# 3.0 language features such as Extension Methods since they are in fact a feature of the C# 3.0 (or .NET 3.5) compiler. See this link: <a href="http://www.codethinked.com/post/2008/02/Using-Extension-Methods-in-net-20.aspx" rel="nofollow noreferrer">http://www.codethinked.com/post/2008/02/Using-Extension-Methods-in-net-20.aspx</a></li>\n</ol>\n'}, {'answer_id': 67422, 'author': 'Aaron Fischer', 'author_id': 5618, 'author_profile': 'https://Stackoverflow.com/users/5618', 'pm_score': 1, 'selected': False, 'text': '<p>There is no benefit to compiling to the 3.5 framework if you are not using any classes from that version of the framework.</p>\n'}, {'answer_id': 68588, 'author': 'Richard McGuire', 'author_id': 5086, 'author_profile': 'https://Stackoverflow.com/users/5086', 'pm_score': 1, 'selected': False, 'text': '<p>I presume that you must mean targeting the .NET 3.5 framework for your compilation?  If so then as others have said I don\'t believe you will see much difference.</p>\n\n<p>However, if you\'re talking about using the updated compilers then there are various changes and break changes described for both C# and VB at the following links:</p>\n\n<ul>\n<li><a href="http://msdn.microsoft.com/en-us/library/bb383815.aspx" rel="nofollow noreferrer">C# 3.0 and SP1 compiler\nchanages</a> </li>\n<li><a href="http://msdn.microsoft.com/en-us/library/x9es5c23.aspx" rel="nofollow noreferrer">What\'s New in the Visual Basic\nCompiler</a> </li>\n<li><a href="http://msdn.microsoft.com/en-us/library/cc714070.aspx" rel="nofollow noreferrer">Visual Basic 2008 Breaking\nChanges</a></li>\n</ul>\n'}, {'answer_id': 68788, 'author': 'Richard McGuire', 'author_id': 5086, 'author_profile': 'https://Stackoverflow.com/users/5086', 'pm_score': 1, 'selected': False, 'text': "<p>I believe that a different compiler ships with each version of Visual Studio.  For example in the case of C# the 2.0 compiler shipped with Visual Studio 2005 and the C# 3.0 shipped with Visual Studio 2008.  Depending upon which version of Visual Studio you use you end up with a different compiler.</p>\n\n<p>Targeting a framework refers to specifically which version of the framework you wish to target during the compilation process; targeting frameworks is a new feature of Visual Studio 2008.  For instance I could have a solution open in Visual Studio 2008 and target v2.0 of .Net.  The result would be that I wouldn't have any of the 3.0 or 3.5 .Net features available to me during that compilation, for example WPF.</p>\n"}, {'answer_id': 71707, 'author': 'Jonas', 'author_id': 9744, 'author_profile': 'https://Stackoverflow.com/users/9744', 'pm_score': 1, 'selected': False, 'text': '<p>If your .NET assembly targets .NET 3.5, the resulting application will look for and require the .NET 3.5 libraries, and that\'s that. These libraries come with numerous additional classed not found in the .NET 2.0 framework, so that would be the advantage to targetting those libraries.</p>\n\n<p>If you however compile C# code with the C# 3.0 compiler shipping with e.g. Visual Studio 2008 and suited for .NET 3.5, <em>but</em> have your assembly target .NET 2.0, you will still only need the regular .NET 2.0 libraries, and despite this actually use certain .NET 3.5 compiler features, as a number of those features are only making use of .NET 2.0 code in the end. Read more about this here: <a href="http://weblogs.asp.net/shahar/archive/2008/01/23/use-c-3-features-from-c-2-and-net-2-0-code.aspx" rel="nofollow noreferrer">http://weblogs.asp.net/shahar/archive/2008/01/23/use-c-3-features-from-c-2-and-net-2-0-code.aspx</a></p>\n'}]
['https://Stackoverflow.com/questions/66759', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/6143/']