title: Detect target framework version at compile time
body: <p>I have some code which makes use of Extension Methods, but compiles under .NET 2.0 using the compiler in VS2008. To facilitate this, I had to declare ExtensionAttribute:</p>
  
  <pre><code>/// &lt;summary&gt;
  /// ExtensionAttribute is required to define extension methods under .NET 2.0
  /// &lt;/summary&gt;
  public sealed class ExtensionAttribute : Attribute
  {
  }
  </code></pre>
  
  <p>However, I'd now like the library in which that class is contained to also be compilable under .NET 3.0, 3.5 and 4.0 - without the 'ExtensionAttribute is defined in multiple places' warning.</p>
  
  <p>Is there any compile time directive I can use to only include the ExtensionAttribute when the framework version being targetted is .NET 2? </p>