3

For a while now, the VBC_VER constant was defined such that you could do things like:

#If VBC_VER >= 9.0 Then
Imports System.Net.Mail
#Else
Imports System.Web.Mail
#End If

Is there an equivalent that can be used in C# code, or a comparison of those constants defined automatically?

Rowland Shaw
  • 37,700
  • 14
  • 97
  • 166

1 Answers1

1

No, not that I'm aware of. You can define your own preprocessor symbols in a project file, of course.

Bear in mind that "version of C#" and "version of .NET that the project is targeting" are not the same thing, either. I would expect which namespaces you want to use to depend more on the framework version you're using than the language version.

Jon Skeet
  • 1,421,763
  • 867
  • 9,128
  • 9,194
  • My use case this time around is for a nice handy constant for async support. I did see that you can [define constants based on the version of the framework being targetted](http://stackoverflow.com/a/7888576/50447), but these don't appear to be able to set a version in the same manner as the old VBC_VER. Looks like my project is about to grow some additional configurations... – Rowland Shaw Oct 01 '12 at 10:40