7

C# is already 7.0. But C# Language Specifications is still for 5.0.

I realize the specifications is outdated when I couldn't find GetValueOrDefault() for a nullable type in the document.

I wonder if the specification has been updated yet, at least for 6.0?

svick
  • 236,525
  • 50
  • 385
  • 514
Tim
  • 1
  • 141
  • 372
  • 590
  • 1
    https://stackoverflow.com/questions/31617711/where-can-i-find-the-c-sharp-language-specification-6-0 – Daniel A. White Apr 01 '17 at 00:57
  • http://stackoverflow.com/documentation/c%23/1936/c-sharp-7-0-features#t=201704010058271350841 – Peter Duniho Apr 01 '17 at 01:03
  • 4
    Note: you will never find `GetValueOrDefault()` in the specification, as that's [part of the CLR](https://msdn.microsoft.com/en-us/library/72cec0e0(v=vs.110).aspx), not the C# specification. – Peter Duniho Apr 01 '17 at 01:04
  • @PeterDuniho do you mean that the programming language implemented by CLR is a strict superset of C#? or do you mean that `GetValueOrDefault()` is in the C# standard library (or the .Net C# library), but not in the C# language? – Tim Apr 01 '17 at 01:34
  • 3
    The CLR doesn't implement a language, so I can't mean that. There's no _"C# standard library"_, so I can't mean that. There is the .NET framework, and that's where `GetValueOrDefault()` is defined. That method has existed since .NET 2.0 (when generic types were introduced, including `Nullable`), and it's not even mentioned in the most recent published specification (C# 5). It's simply not, nor ever is likely to be, a part of the language specification. It's in a completely different part of .NET. – Peter Duniho Apr 01 '17 at 02:32
  • @Peter then in C# 6.0, how can i achieve the same without having `GetValueOrDefault(T defaultValue)`? – Tim Apr 01 '17 at 02:34
  • https://referencesource.microsoft.com/#mscorlib/system/nullable.cs,8b928034cfee7d43. Not really sure what you mean by "achieve the same", or why you'd find yourself _"without having `GetValueOrDefault()`"_, but the source code is there for anyone to review. You can base any alternate implementation on the example there (not that it's exactly rocket science or anything). – Peter Duniho Apr 01 '17 at 02:36
  • 1
    Possible duplicate of [Where Can I Find the C# Language Specification 6.0?](http://stackoverflow.com/questions/31617711/where-can-i-find-the-c-sharp-language-specification-6-0) – Dan Field Apr 01 '17 at 02:55
  • 5
    This question isn't off-topic. It doesn't ask a recommendation for a book. It asks for the location and status of C#'s reference. That's a valid question. of concern to most C# developers. Given the *unofficial* status of the current reference, it's also something that can't be answered by 1-year old answers – Panagiotis Kanavos Apr 03 '17 at 07:52
  • @PanagiotisKanavos Instead of creating yet another Question & Answer that will be outdated in 1 year, why not rather put related information in specific tag (C#-6, C#-7) info? – Filburt Apr 05 '17 at 15:34

2 Answers2

12

The current status is:

But those are just specifications of the C# language, they don't specify types and members that exist in the base class library (with some exceptions that are required for various language features). Until recently, each framework defined its library on its own, but now even that is standardized, though the .Net Standard.

svick
  • 236,525
  • 50
  • 385
  • 514
4

I have not found any official language specifications for C# 6 and 7 on Microsoft or ECMA site, but here are few links.

While Microsoft's documentation for C# 6 and 7 at these links is succinct, the StackOverflow pages have lots of examples, details and cover gotchas.

For C# 7

What's new in C# 7 on Microsoft website.

For C# 6

What's New in C# 6 on Microsoft website.

For C# 5 and older versions

If someone stumbles upon this question looking for C# version 5, 4 or 2 specifications, Jon Skeet at C# in Depth page has put together a nice collection of all the specifications.

P.S. I am intentionally pasting an image snapshot of his page (instead of contents in text format) so I don't take the traffic away from his page.

enter image description here

Graham
  • 7,431
  • 18
  • 59
  • 84
HappyTown
  • 6,036
  • 8
  • 38
  • 51
  • 3
    *"I am intentionally pasting an image snapshot of his page (instead of contents in text format) so I don't take the traffic away from his page."* Isn't that why Al Gore created hyperlinks? – Cody Gray - on strike Apr 01 '17 at 06:01
  • 2
    For the record, I have absolutely no problem with the links being included directly. – Jon Skeet Apr 01 '17 at 09:44