-1

I've been reading various articles and questions about C# versions (including the Jon Skeet's answer here on SO). However, I was unable to understand a simple (I hope) thing. How CLR, .NET and C# versions are related? For example, is it possible to use the C# compiler which supports C# 6 and run the resulting IL code under the CLR 1? For instance, when the support of async/await was added, did the CLR have to change or was it not needed just because the async/await compiles into the plain IL? I am quite familiar with the .NET basics, however, I do not understand which changes are made into C# with each version. How exactly is the support of async/await, lambdas and other stuff added to the language? Do they require the changes to .NET framework or CLR?

This answer says C# 4 requires CLR 4. What is meant by requires? As I understood, some features will still work under the lower CLR version.

Community
  • 1
  • 1
Vlad Stryapko
  • 1,035
  • 11
  • 29

1 Answers1

2

If you compile against CLR Version X you can run your code only on that version.

For backwards compatibility each CLR version brings the older CLRs to your computer. So if you install CLR 4 it will also install CLR 2 and CLR 1.

So you can run code compiled against CLR 1 on a computer where CLR 4 has been installed. But not the other way around.