{"action":"created","comment":{"url":"https://api.github.com/repos/dotnet/core-docs/pulls/comments/80262251","id":80262251,"diff_hunk":"@@ -1,17 +1,570 @@\n ---\n title: What's New in C# 6 | C# Guide\n-description: What's New in C# 6    \n+description: Learn the new features in C# Version 6    \n keywords: .NET, .NET Core\n-author:  tdykstra\n+author:  BillWagner\n manager: wpickett\n-ms.date: 06/20/2016\n+ms.date: 09/22/2016\n ms.topic: article\n-ms.prod: .net-core\n-ms.technology: .net-core-technologies\n-ms.devlang: dotnet\n+ms.prod: visual-studio-dev-14\n+ms.technology: devlang-csharp\n+ms.devlang: csharp\n ms.assetid: 4d879f69-f889-4d3f-a781-75194e143400\n ---\n \n-# What's New in C# 6    \n-    \n-For information about new features in C# 6, we suggest you head over to [the Roslyn repository in GitHub](https://github.com/dotnet/roslyn/wiki/New-Language-Features-in-C%23-6).\n+# What's New in C# 6\n+\n+The 6.0 release of C# contained many features that improves\n+productivity for developers. Features in this release include:\n+\n+* [Readonly Auto properties](#readonly-auto-properties)\n+* [Auto Property Initializers](#auto-property-initializers)\n+* [Expression Bodied function members](#expression-bodied-function-members)\n+* [using static](#using-static)\n+* [Null - conditional operators](#null-conditional-operators)\n+* [String Interpolation](#string-interpolation)\n+* [Exception filters](#exception-filters)\n+* [nameof Expressions](#nameof-expressions)\n+* [await in catch and finally blocks](#await-in-catch-and-finally-blocks)\n+* [index initializers](#index-initializers)\n+* [Extension methods for collection initializers](#extension-add-methods-in-collection-initializers)\n+* [Improved overload resolution](#improved-overload-resolution)\n+\n+The overall effect of these features is that you write more concise code\n+that is also more readable. The syntax contains less ceremony for many\n+common practices. It's easier to see the design intent with less\n+ceremony. Learn these features well, and you'll be more productive,\n+write more readable code, and concentrate more on your core features\n+than on the constructs of the language.\n+\n+The remainder of this topic provides details on each these features.\n+\n+## Auto Property enhancements \n+\n+The syntax for auto-properties made it very easy to create properties\n+that had simple get and set accessors:\n+\n+[!code-csharp[ClassicAutoProperty](../../samples/snippets/csharp/new-in-6/oldcode.cs#ClassicAutoProperty)]\n+\n+However, this simple syntax limited the kinds of designs you could support using\n+auto properties. C# 6 improves the auto properties capabilities so that you can use\n+them in more scenarios. You'll fall back on the more verbose syntax of declaring\n+the backing field by hand, and manipulating that backing field less often.\n+\n+The new syntax addresses scenarios for read only properties, and for initializing\n+the variable storage behind an auto-property.\n+\n+### Readonly auto-properties\n+\n+***Readonly auto-properties*** provide a more concise syntax to create\n+immutable types. The closest you could get to immutable types\n+in earlier versions of C# was to declare private setters:\n+\n+[!code-csharp[ClassicReadOnlyAutoProperty](../../samples/snippets/csharp/new-in-6/oldcode.cs#ClassicReadOnlyAutoProperty)]\n+ \n+Using this syntax, the compiler doesn't ensure that the type really is immutable. It only\n+enforces that the `FirstName` and `LastName` properties are not modified from any\n+code outisde the class.\n+\n+Readonly auto-properties enable true readonly behavior. You declare the auto-property\n+with only a get accessor:\n+\n+[!code-csharp[ReadOnlyAutoProperty](../../samples/snippets/csharp/new-in-6/newcode.cs#ReadOnlyAutoProperty)]\n+\n+The `FirstName` and `LastName` properties can be set only in the body of a constructor:\n+\n+[!code-csharp[ReadOnlyAutoPropertyConstructor](../../samples/snippets/csharp/new-in-6/newcode.cs#ReadOnlyAutoPropertyConstructor)]\n+\n+Trying to set `LastName` in another method generates a `CS0200` compilation error:\n+\n+```csharp\n+public class Student\n+{\n+    public string LastName { get;  }\n+\n+    public void ChangeName(string newLastName)\n+    {\n+        // Generates CS 0200: Property or indexer cannot be assigned to -- it is read only\n+        LastName = newLastName;\n+    }\n+}\n+```\n+\n+This features enables true language support for creating immutable types and using\n+the more concise and convenient auto-property syntax.\n+\n+### Auto Property Initializers\n+\n+***Auto Property Initializers*** let you declare the initial value for\n+an auto property as part of the property declaration.  In earlier versions,\n+these properties would need to have setters and a class author would need\n+to use that setter to initialize the data storage used by the backing\n+field. Consider this class for a student that contains the name and a\n+list of the student's grades:\n+\n+[!code-csharp[Construction](../../samples/snippets/csharp/new-in-6/oldcode.cs#Construction)]\n+ \n+As this class grows, you may include other constructors. Each constructor\n+needs to initialize this field, or you'll introduce errors.\n+\n+C# 6 enables you to assign an initial value for the storage used by an\n+auto property in the auto property declaration:\n+\n+[!code-csharp[Initialization](../../samples/snippets/csharp/new-in-6/newcode.cs#Initialization)]\n+\n+The `grades` member is initialized where it is declared. That makes it\n+easier to perform the initialization exactly once. The initialization\n+is part of the property declaration, making it easier to equate the\n+storage allocation with public interface for `Student` objects.\n+\n+Property Initializers can be used with read / write properties as well","path":"docs/csharp/csharp-6.md","position":129,"original_position":129,"commit_id":"129c7351119cc711c5557db93459a16d50398e4e","original_commit_id":"129c7351119cc711c5557db93459a16d50398e4e","user":{"login":"BillWagner","id":493969,"avatar_url":"https://avatars.githubusercontent.com/u/493969?v=3","gravatar_id":"","url":"https://api.github.com/users/BillWagner","html_url":"https://github.com/BillWagner","followers_url":"https://api.github.com/users/BillWagner/followers","following_url":"https://api.github.com/users/BillWagner/following{/other_user}","gists_url":"https://api.github.com/users/BillWagner/gists{/gist_id}","starred_url":"https://api.github.com/users/BillWagner/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/BillWagner/subscriptions","organizations_url":"https://api.github.com/users/BillWagner/orgs","repos_url":"https://api.github.com/users/BillWagner/repos","events_url":"https://api.github.com/users/BillWagner/events{/privacy}","received_events_url":"https://api.github.com/users/BillWagner/received_events","type":"User","site_admin":false},"body":"fixed.","created_at":"2016-09-23T15:00:24Z","updated_at":"2016-09-23T15:00:25Z","html_url":"https://github.com/dotnet/core-docs/pull/1068#discussion_r80262251","pull_request_url":"https://api.github.com/repos/dotnet/core-docs/pulls/1068","_links":{"self":{"href":"https://api.github.com/repos/dotnet/core-docs/pulls/comments/80262251"},"html":{"href":"https://github.com/dotnet/core-docs/pull/1068#discussion_r80262251"},"pull_request":{"href":"https://api.github.com/repos/dotnet/core-docs/pulls/1068"}}},"pull_request":{"url":"https://api.github.com/repos/dotnet/core-docs/pulls/1068","id":86401395,"html_url":"https://github.com/dotnet/core-docs/pull/1068","diff_url":"https://github.com/dotnet/core-docs/pull/1068.diff","patch_url":"https://github.com/dotnet/core-docs/pull/1068.patch","issue_url":"https://api.github.com/repos/dotnet/core-docs/issues/1068","number":1068,"state":"open","locked":false,"title":"Whats new in csharp 6","user":{"login":"BillWagner","id":493969,"avatar_url":"https://avatars.githubusercontent.com/u/493969?v=3","gravatar_id":"","url":"https://api.github.com/users/BillWagner","html_url":"https://github.com/BillWagner","followers_url":"https://api.github.com/users/BillWagner/followers","following_url":"https://api.github.com/users/BillWagner/following{/other_user}","gists_url":"https://api.github.com/users/BillWagner/gists{/gist_id}","starred_url":"https://api.github.com/users/BillWagner/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/BillWagner/subscriptions","organizations_url":"https://api.github.com/users/BillWagner/orgs","repos_url":"https://api.github.com/users/BillWagner/repos","events_url":"https://api.github.com/users/BillWagner/events{/privacy}","received_events_url":"https://api.github.com/users/BillWagner/received_events","type":"User","site_admin":false},"body":"Fixes #680.\r\n\r\nReady for review.\r\n\r\nThis is longer than I would like. I welcome any ideas to break it up.","created_at":"2016-09-22T19:42:25Z","updated_at":"2016-09-23T15:00:25Z","closed_at":null,"merged_at":null,"merge_commit_sha":"bc7fa31f5a9ed4f47694c6e48824b6455192de57","assignee":null,"assignees":[],"milestone":null,"commits_url":"https://api.github.com/repos/dotnet/core-docs/pulls/1068/commits","review_comments_url":"https://api.github.com/repos/dotnet/core-docs/pulls/1068/comments","review_comment_url":"https://api.github.com/repos/dotnet/core-docs/pulls/comments{/number}","comments_url":"https://api.github.com/repos/dotnet/core-docs/issues/1068/comments","statuses_url":"https://api.github.com/repos/dotnet/core-docs/statuses/129c7351119cc711c5557db93459a16d50398e4e","head":{"label":"BillWagner:whats-new-in-csharp-6","ref":"whats-new-in-csharp-6","sha":"129c7351119cc711c5557db93459a16d50398e4e","user":{"login":"BillWagner","id":493969,"avatar_url":"https://avatars.githubusercontent.com/u/493969?v=3","gravatar_id":"","url":"https://api.github.com/users/BillWagner","html_url":"https://github.com/BillWagner","followers_url":"https://api.github.com/users/BillWagner/followers","following_url":"https://api.github.com/users/BillWagner/following{/other_user}","gists_url":"https://api.github.com/users/BillWagner/gists{/gist_id}","starred_url":"https://api.github.com/users/BillWagner/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/BillWagner/subscriptions","organizations_url":"https://api.github.com/users/BillWagner/orgs","repos_url":"https://api.github.com/users/BillWagner/repos","events_url":"https://api.github.com/users/BillWagner/events{/privacy}","received_events_url":"https://api.github.com/users/BillWagner/received_events","type":"User","site_admin":false},"repo":{"id":45638874,"name":"core-docs","full_name":"BillWagner/core-docs","owner":{"login":"BillWagner","id":493969,"avatar_url":"https://avatars.githubusercontent.com/u/493969?v=3","gravatar_id":"","url":"https://api.github.com/users/BillWagner","html_url":"https://github.com/BillWagner","followers_url":"https://api.github.com/users/BillWagner/followers","following_url":"https://api.github.com/users/BillWagner/following{/other_user}","gists_url":"https://api.github.com/users/BillWagner/gists{/gist_id}","starred_url":"https://api.github.com/users/BillWagner/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/BillWagner/subscriptions","organizations_url":"https://api.github.com/users/BillWagner/orgs","repos_url":"https://api.github.com/users/BillWagner/repos","events_url":"https://api.github.com/users/BillWagner/events{/privacy}","received_events_url":"https://api.github.com/users/BillWagner/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/BillWagner/core-docs","description":".NET Core documentation (work in progress).","fork":true,"url":"https://api.github.com/repos/BillWagner/core-docs","forks_url":"https://api.github.com/repos/BillWagner/core-docs/forks","keys_url":"https://api.github.com/repos/BillWagner/core-docs/keys{/key_id}","collaborators_url":"https://api.github.com/repos/BillWagner/core-docs/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/BillWagner/core-docs/teams","hooks_url":"https://api.github.com/repos/BillWagner/core-docs/hooks","issue_events_url":"https://api.github.com/repos/BillWagner/core-docs/issues/events{/number}","events_url":"https://api.github.com/repos/BillWagner/core-docs/events","assignees_url":"https://api.github.com/repos/BillWagner/core-docs/assignees{/user}","branches_url":"https://api.github.com/repos/BillWagner/core-docs/branches{/branch}","tags_url":"https://api.github.com/repos/BillWagner/core-docs/tags","blobs_url":"https://api.github.com/repos/BillWagner/core-docs/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/BillWagner/core-docs/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/BillWagner/core-docs/git/refs{/sha}","trees_url":"https://api.github.com/repos/BillWagner/core-docs/git/trees{/sha}","statuses_url":"https://api.github.com/repos/BillWagner/core-docs/statuses/{sha}","languages_url":"https://api.github.com/repos/BillWagner/core-docs/languages","stargazers_url":"https://api.github.com/repos/BillWagner/core-docs/stargazers","contributors_url":"https://api.github.com/repos/BillWagner/core-docs/contributors","subscribers_url":"https://api.github.com/repos/BillWagner/core-docs/subscribers","subscription_url":"https://api.github.com/repos/BillWagner/core-docs/subscription","commits_url":"https://api.github.com/repos/BillWagner/core-docs/commits{/sha}","git_commits_url":"https://api.github.com/repos/BillWagner/core-docs/git/commits{/sha}","comments_url":"https://api.github.com/repos/BillWagner/core-docs/comments{/number}","issue_comment_url":"https://api.github.com/repos/BillWagner/core-docs/issues/comments{/number}","contents_url":"https://api.github.com/repos/BillWagner/core-docs/contents/{+path}","compare_url":"https://api.github.com/repos/BillWagner/core-docs/compare/{base}...{head}","merges_url":"https://api.github.com/repos/BillWagner/core-docs/merges","archive_url":"https://api.github.com/repos/BillWagner/core-docs/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/BillWagner/core-docs/downloads","issues_url":"https://api.github.com/repos/BillWagner/core-docs/issues{/number}","pulls_url":"https://api.github.com/repos/BillWagner/core-docs/pulls{/number}","milestones_url":"https://api.github.com/repos/BillWagner/core-docs/milestones{/number}","notifications_url":"https://api.github.com/repos/BillWagner/core-docs/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/BillWagner/core-docs/labels{/name}","releases_url":"https://api.github.com/repos/BillWagner/core-docs/releases{/id}","deployments_url":"https://api.github.com/repos/BillWagner/core-docs/deployments","created_at":"2015-11-05T20:57:32Z","updated_at":"2016-06-25T02:34:01Z","pushed_at":"2016-09-22T19:16:16Z","git_url":"git://github.com/BillWagner/core-docs.git","ssh_url":"git@github.com:BillWagner/core-docs.git","clone_url":"https://github.com/BillWagner/core-docs.git","svn_url":"https://github.com/BillWagner/core-docs","homepage":"http://dotnet.readthedocs.org","size":17257,"stargazers_count":1,"watchers_count":1,"language":"PowerShell","has_issues":false,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":1,"mirror_url":null,"open_issues_count":0,"forks":1,"open_issues":0,"watchers":1,"default_branch":"master"}},"base":{"label":"dotnet:master","ref":"master","sha":"b92e1e484cf3f08edb90c0b6144be9ce54d733a4","user":{"login":"dotnet","id":9141961,"avatar_url":"https://avatars.githubusercontent.com/u/9141961?v=3","gravatar_id":"","url":"https://api.github.com/users/dotnet","html_url":"https://github.com/dotnet","followers_url":"https://api.github.com/users/dotnet/followers","following_url":"https://api.github.com/users/dotnet/following{/other_user}","gists_url":"https://api.github.com/users/dotnet/gists{/gist_id}","starred_url":"https://api.github.com/users/dotnet/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/dotnet/subscriptions","organizations_url":"https://api.github.com/users/dotnet/orgs","repos_url":"https://api.github.com/users/dotnet/repos","events_url":"https://api.github.com/users/dotnet/events{/privacy}","received_events_url":"https://api.github.com/users/dotnet/received_events","type":"Organization","site_admin":false},"repo":{"id":35890081,"name":"core-docs","full_name":"dotnet/core-docs","owner":{"login":"dotnet","id":9141961,"avatar_url":"https://avatars.githubusercontent.com/u/9141961?v=3","gravatar_id":"","url":"https://api.github.com/users/dotnet","html_url":"https://github.com/dotnet","followers_url":"https://api.github.com/users/dotnet/followers","following_url":"https://api.github.com/users/dotnet/following{/other_user}","gists_url":"https://api.github.com/users/dotnet/gists{/gist_id}","starred_url":"https://api.github.com/users/dotnet/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/dotnet/subscriptions","organizations_url":"https://api.github.com/users/dotnet/orgs","repos_url":"https://api.github.com/users/dotnet/repos","events_url":"https://api.github.com/users/dotnet/events{/privacy}","received_events_url":"https://api.github.com/users/dotnet/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/dotnet/core-docs","description":"This repository contains .NET Documentation.","fork":false,"url":"https://api.github.com/repos/dotnet/core-docs","forks_url":"https://api.github.com/repos/dotnet/core-docs/forks","keys_url":"https://api.github.com/repos/dotnet/core-docs/keys{/key_id}","collaborators_url":"https://api.github.com/repos/dotnet/core-docs/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/dotnet/core-docs/teams","hooks_url":"https://api.github.com/repos/dotnet/core-docs/hooks","issue_events_url":"https://api.github.com/repos/dotnet/core-docs/issues/events{/number}","events_url":"https://api.github.com/repos/dotnet/core-docs/events","assignees_url":"https://api.github.com/repos/dotnet/core-docs/assignees{/user}","branches_url":"https://api.github.com/repos/dotnet/core-docs/branches{/branch}","tags_url":"https://api.github.com/repos/dotnet/core-docs/tags","blobs_url":"https://api.github.com/repos/dotnet/core-docs/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/dotnet/core-docs/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/dotnet/core-docs/git/refs{/sha}","trees_url":"https://api.github.com/repos/dotnet/core-docs/git/trees{/sha}","statuses_url":"https://api.github.com/repos/dotnet/core-docs/statuses/{sha}","languages_url":"https://api.github.com/repos/dotnet/core-docs/languages","stargazers_url":"https://api.github.com/repos/dotnet/core-docs/stargazers","contributors_url":"https://api.github.com/repos/dotnet/core-docs/contributors","subscribers_url":"https://api.github.com/repos/dotnet/core-docs/subscribers","subscription_url":"https://api.github.com/repos/dotnet/core-docs/subscription","commits_url":"https://api.github.com/repos/dotnet/core-docs/commits{/sha}","git_commits_url":"https://api.github.com/repos/dotnet/core-docs/git/commits{/sha}","comments_url":"https://api.github.com/repos/dotnet/core-docs/comments{/number}","issue_comment_url":"https://api.github.com/repos/dotnet/core-docs/issues/comments{/number}","contents_url":"https://api.github.com/repos/dotnet/core-docs/contents/{+path}","compare_url":"https://api.github.com/repos/dotnet/core-docs/compare/{base}...{head}","merges_url":"https://api.github.com/repos/dotnet/core-docs/merges","archive_url":"https://api.github.com/repos/dotnet/core-docs/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/dotnet/core-docs/downloads","issues_url":"https://api.github.com/repos/dotnet/core-docs/issues{/number}","pulls_url":"https://api.github.com/repos/dotnet/core-docs/pulls{/number}","milestones_url":"https://api.github.com/repos/dotnet/core-docs/milestones{/number}","notifications_url":"https://api.github.com/repos/dotnet/core-docs/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/dotnet/core-docs/labels{/name}","releases_url":"https://api.github.com/repos/dotnet/core-docs/releases{/id}","deployments_url":"https://api.github.com/repos/dotnet/core-docs/deployments","created_at":"2015-05-19T15:13:32Z","updated_at":"2016-09-22T17:54:22Z","pushed_at":"2016-09-23T06:14:10Z","git_url":"git://github.com/dotnet/core-docs.git","ssh_url":"git@github.com:dotnet/core-docs.git","clone_url":"https://github.com/dotnet/core-docs.git","svn_url":"https://github.com/dotnet/core-docs","homepage":"https://docs.microsoft.com/dotnet","size":21819,"stargazers_count":234,"watchers_count":234,"language":"PowerShell","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":338,"mirror_url":null,"open_issues_count":179,"forks":338,"open_issues":179,"watchers":234,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/dotnet/core-docs/pulls/1068"},"html":{"href":"https://github.com/dotnet/core-docs/pull/1068"},"issue":{"href":"https://api.github.com/repos/dotnet/core-docs/issues/1068"},"comments":{"href":"https://api.github.com/repos/dotnet/core-docs/issues/1068/comments"},"review_comments":{"href":"https://api.github.com/repos/dotnet/core-docs/pulls/1068/comments"},"review_comment":{"href":"https://api.github.com/repos/dotnet/core-docs/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/dotnet/core-docs/pulls/1068/commits"},"statuses":{"href":"https://api.github.com/repos/dotnet/core-docs/statuses/129c7351119cc711c5557db93459a16d50398e4e"}}}}
{"actor":{"display_login":"BillWagner"}}