0 out of 1 rated this helpful - Rate this topic

/langversion (C# Compiler Options)

Causes the compiler to accept only syntax that is included in the chosen C# language specification.

/langversion:option
option

The following values are valid:

Option

Meaning

default

The compiler accepts all valid language syntax.

ISO-1

The compiler accepts only syntax that is included in the ISO/IEC 23270:2003 C# language specification.

ISO-2

The compiler accepts only syntax that is included in the ISO/IEC 23270:2006 C# language specification. This specification is available on the ISO Web site.

3

The compiler accepts only syntax that is included in the version 3.0 C# Language Specification.

Metadata referenced by your C# application is not subject to /langversion compiler option.

Because each version of the C# compiler contains extensions to the language specification, /langversion does not give you the equivalent functionality of an earlier version of the compiler.

Regardless of which /langversion setting you use, you will use the current version of the common language runtime to create your .exe or .dll. One exception is friend assemblies and /moduleassemblyname (C# Compiler Option), which work under /langversion:ISO-1.

To set this compiler option in the Visual Studio development environment

  1. Open the project's Properties page.

  2. Click the Build property page.

  3. Click the Advanced button.

  4. Modify the Language Version property.

For information about how to set this compiler option programmatically, see LanguageVersion.

Did you find this helpful?
(1500 characters remaining)
Community Content Add
Annotations FAQ
Am I missing something
We tried adding the 3 value to our 2010 solution (in each project file); with the aim that we would not use any code features that are not available in Visual Studio 2008 (which some of the developers still use). Only to find that the flag is incompatible with visual studio 2008! So we had to remove it again.

I am hoping that there is already a 2010 langversion flag that is not in this list that visual studio 2010 will allow, or this flag is going to continue to be ineffective at solving this sort of issue without having separate project files for each visual studio version as well as separate solution files.