C# 7 - Favorites

9/15/2017

C# version 7.0 was released with Visual Studio 2017. Here is my list of favorite additions:

Tuples

There are plenty of times when I need a simple light-weight type containing multiple fields. Being generics make them super simple to work with.

async Main method
It sure helps to now have Main be defined async. So this:
static int Main()
{
    return DoAsyncWork().GetAwaiter().GetResult();
}

Can now become:

static async Task<int> Main()
{
    return await DoAsyncWork();
}

private protected access modifier

(from MS documentation:) A new compound access modifier: private protected indicates that a member may be accessed by containing class or derived classes that are declared in the same assembly. While protected internal allows access by derived classes or classes that are in the same assembly, private protected limits access to derived types declared in the same assembly.


Please register or login to add a comment.

Comments (displaying 1 - 1):
No comments yet! Be the first...


  • C#/.NET
  • T-SQL
  • HTML/CSS
  • JavaScript/jQuery
  • .NET 8
  • ASP.NET/MVC
  • Xamarin/MAUI
  • WPF
  • Windows 11
  • SQL Server 20xx
  • Android
  • XBox
  • Arduino
  • Skiing
  • Rock Climbing
  • White water kayaking
  • Road Biking