{"id":121,"date":"2017-02-23T20:44:57","date_gmt":"2017-02-24T01:44:57","guid":{"rendered":"http:\/\/langstonsoftware.com\/?p=121"},"modified":"2024-01-30T19:09:17","modified_gmt":"2024-01-31T00:09:17","slug":"getting-excited-about-c-7-0-tuples","status":"publish","type":"post","link":"https:\/\/langstonsoftware.com\/2017\/02\/23\/getting-excited-about-c-7-0-tuples\/","title":{"rendered":"Getting Excited About C# 7.0 Tuples"},"content":{"rendered":"

I’ve had the good luck to work on a number of legacy (read: profitable, stable) enterprise code bases. While appreciate all the benefits that such work entails, sometimes it means others may be getting into the new hotness, while my work is rather cool to the idea of adopting the latest platform developments.<\/p>\n

But eventually, legacy systems do move into the future. So it is with a great deal of excitement that I’ve been finding my self reading and rereading half a year old spoilers i.e. language road\u00a0blogs for C# 7.0.<\/p>\n

https:\/\/blogs.msdn.microsoft.com\/dotnet\/2016\/08\/24\/whats-new-in-csharp-7-0\/<\/p>\n

Tuples in particular are practically making me squeal with glee. Here’s the basic form:<\/p>\n

\r\npublic (string fullName, int id, bool isFaculty) GetRegistrant(string[] email)\r\n{\r\n  \/\/Retrieve registrant info into local variables  \r\n  return (fullName: fN, id: i, isFaculty: iF)\r\n}\r\n\r\npublic static void Main()\r\n{\r\n    var registrant = GetRegistrant("test@example.com);\r\n    Console.WriteLine($"Hello {registrant.fullName}!");\r\n    var (name, number, occupation) = GetRegistrant("another@example.com";\r\n    Console.WriteLine($"Your ID is {number}");\r\n}\r\n<\/pre>\n

Check out the blog for more details, but here are the key features I enjoy.<\/p>\n

Out variables are terrible.<\/strong> Anything that lets me use less of them is a good thing.<\/p>\n

Custom return types are boilerplate.<\/strong> Removing ceremony while retaining type safety is amazing.
\n
\nTuples with unnamed item members are never self documenting code. <\/strong> I’m tired of having to go back to the calling code to clarify if it was the first int or the second that was my ID.<\/p>\n

These factors together make Tuples the changes I looking forward to most when my legacy code base in updated.<\/p>\n

What’s your favorite feature of C# 7.0? Leave a comment below and tell me.<\/p>\n","protected":false},"excerpt":{"rendered":"

I’ve had the good luck to work on a number of legacy (read: profitable, stable) enterprise code bases. While appreciate all the benefits that such work entails, sometimes it means others may be getting into the new hotness, while my work is rather cool to the idea of adopting the latest platform developments. But eventually, …<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"nf_dc_page":"","jetpack_post_was_ever_published":false,"_jetpack_newsletter_access":"","_jetpack_dont_email_post_to_subs":false,"_jetpack_newsletter_tier_id":0,"_jetpack_memberships_contains_paywalled_content":false,"_jetpack_memberships_contains_paid_content":false,"footnotes":"","jetpack_publicize_message":"","jetpack_publicize_feature_enabled":true,"jetpack_social_post_already_shared":true,"jetpack_social_options":{"image_generator_settings":{"template":"highway","enabled":false},"version":2}},"categories":[2],"tags":[],"class_list":["post-121","post","type-post","status-publish","format-standard","hentry","category-c"],"jetpack_publicize_connections":[],"jetpack_featured_media_url":"","jetpack_sharing_enabled":true,"jetpack_shortlink":"https:\/\/wp.me\/p6Os38-1X","_links":{"self":[{"href":"https:\/\/langstonsoftware.com\/wp-json\/wp\/v2\/posts\/121"}],"collection":[{"href":"https:\/\/langstonsoftware.com\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/langstonsoftware.com\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/langstonsoftware.com\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/langstonsoftware.com\/wp-json\/wp\/v2\/comments?post=121"}],"version-history":[{"count":6,"href":"https:\/\/langstonsoftware.com\/wp-json\/wp\/v2\/posts\/121\/revisions"}],"predecessor-version":[{"id":128,"href":"https:\/\/langstonsoftware.com\/wp-json\/wp\/v2\/posts\/121\/revisions\/128"}],"wp:attachment":[{"href":"https:\/\/langstonsoftware.com\/wp-json\/wp\/v2\/media?parent=121"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/langstonsoftware.com\/wp-json\/wp\/v2\/categories?post=121"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/langstonsoftware.com\/wp-json\/wp\/v2\/tags?post=121"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}