Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Difference between compiling as C# 3.0 or ISO-1 or ISO-2?

In Visual Studio 2010, under "Advanced Build Settings" there is the following options for "Language Version":

  • default
  • ISO-1
  • ISO-2
  • C# 3.0

Is there any advantage to compiling as C# 3.0, e.g. benchmark speed or stability?

like image 457
Contango Avatar asked Feb 07 '12 09:02

Contango


People also ask

Is C and C++ compiler different?

It does dynamic memory allocation and deallocation using the new and delete keywords. C compilers cannot execute C++ programs. C++ compilers can execute almost all programs that are written in C, as C++ is an extension and superset of C itself. There are a total of 32 keywords in the C programming language.

What is difference between compile and run in C?

Compile time is the period when the programming code (such as C#, Java, C, Python) is converted to the machine code (i.e. binary code). Runtime is the period of time when a program is running and generally occurs after compile time.

What does compiling mean in C?

Compiling a C Program. Compiling is the transformation from Source Code (human readable) into machine code (computer executable). A compiler is a program.

What is the difference between different C compilers?

Some compilers cost you money - others are free - some produce better machine code than others - some are more up to date with the latest revision of the specification. Some produce more helpful error messages - others are more terse. Honestly - it's mostly a matter of preference.


2 Answers

The only time you should mess with this is if you are writing code in, say, VS 2010, but you intend that the code should compile on earlier compilers (VS 2005 or VS 2003). This will limit language features, such as LINQ (only in C# 3), iterator blocks (only in ISO-2 and above), etc.

Even then, it is not robust; there are some features that are pretty awkward to detect, and won't be detected - some forms of generic type inference are impacted by this, so you should still test against an earlier compiler.

Unless you have a reason, use "default". Normally, "default" is selected by, er, default. If it is selecting ISO-1, then you have changed your VS settings at some point.

There is not usually any speed difference associated with this - it is about the langauge that is available; however, I have not checked on some subtle cases, for example does the field-like-event implementation revert to the old-way if an earlier compiler selected.

like image 92
Marc Gravell Avatar answered Sep 19 '22 11:09

Marc Gravell


Leave this on default. This means that you can use all of the C# 3.0 language features.

Press "F1", and it comes up with:

http://msdn.microsoft.com/en-us/library/f4ckecs0(v=vs.110).aspx

  • 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.
  • C# 3 The compiler accepts only syntax that is included in the version 3.0 C# Language Specification.
like image 35
Contango Avatar answered Sep 22 '22 11:09

Contango