{"id":26349,"date":"2019-08-21T16:46:35","date_gmt":"2019-08-21T20:46:35","guid":{"rendered":"https:\/\/mjtsai.com\/blog\/?p=26349"},"modified":"2019-08-21T16:46:35","modified_gmt":"2019-08-21T20:46:35","slug":"nullable-references-in-c-8-0","status":"publish","type":"post","link":"https:\/\/mjtsai.com\/blog\/2019\/08\/21\/nullable-references-in-c-8-0\/","title":{"rendered":"Nullable References in C# 8.0"},"content":{"rendered":"<p><a href=\"https:\/\/ericsink.com\/entries\/cs8_nullable_references.html\">Erik Sink<\/a>:<\/p>\n<blockquote cite=\"https:\/\/ericsink.com\/entries\/cs8_nullable_references.html\">\n<p>Bottom line, C# 8.0 uses the same syntax for nullability of reference types that we have been using for value types:<\/p>\n<pre>string  x; \/\/ not nullable\nstring? y; \/\/     nullable<\/pre>\n<p>And yes, that means that the meaning of a type declaration like <code>string<\/code> (without the <code>?<\/code>) has changed.<\/p>\n<p>Whoa, isn&rsquo;t that a massive break in compatibility? Actually no. In fact, although this feature looks like a huge breaking change, the entire thing was carefully designed to preserve backward compatibility.<\/p>\n<p>First of all, this whole feature is turned off by default, and has to be explicitly turned on. Second, all it really does is generate warnings.<\/p>\n<\/blockquote>\n<p>This seems not that different from nullability in Objective-C, only with cleaner syntax.<\/p>","protected":false},"excerpt":{"rendered":"<p>Erik Sink: Bottom line, C# 8.0 uses the same syntax for nullability of reference types that we have been using for value types: string x; \/\/ not nullable string? y; \/\/ nullable And yes, that means that the meaning of a type declaration like string (without the ?) has changed. Whoa, isn&rsquo;t that a massive [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"apple_news_api_created_at":"2019-08-21T20:46:39Z","apple_news_api_id":"d1a430c9-d7d1-4190-8aed-b5a7569bb42f","apple_news_api_modified_at":"2019-08-21T20:46:41Z","apple_news_api_revision":"AAAAAAAAAAD\/\/\/\/\/\/\/\/\/\/w==","apple_news_api_share_url":"https:\/\/apple.news\/A0aQwydfRQZCK7bWnVpu0Lw","apple_news_coverimage":0,"apple_news_coverimage_caption":"","apple_news_is_hidden":false,"apple_news_is_paid":false,"apple_news_is_preview":false,"apple_news_is_sponsored":false,"apple_news_maturity_rating":"","apple_news_metadata":"\"\"","apple_news_pullquote":"","apple_news_pullquote_position":"","apple_news_slug":"","apple_news_sections":"\"\"","apple_news_suppress_video_url":false,"apple_news_use_image_component":false,"footnotes":""},"categories":[4],"tags":[351,46,71],"class_list":["post-26349","post","type-post","status-publish","format-standard","hentry","category-programming-category","tag-c-sharp","tag-languagedesign","tag-programming"],"apple_news_notices":[],"_links":{"self":[{"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/posts\/26349","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/comments?post=26349"}],"version-history":[{"count":1,"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/posts\/26349\/revisions"}],"predecessor-version":[{"id":26350,"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/posts\/26349\/revisions\/26350"}],"wp:attachment":[{"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/media?parent=26349"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/categories?post=26349"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/tags?post=26349"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}