Switch statement with non-constant-expression - Extends C#/IDE ability
问题 Before you start criticizing and pointing me §8.7.2 of C# specification, read carefully :) We all know how switch looks like in C#. Ok so consider the class MainWindow with "nasty" Bar method static int barCounter = 0; public static int Bar() { return ++barCounter; } Somewhere in this class we have code like this Action switchCode = () => { switch (Bar()) { case 1: Console.WriteLine("First"); break; case 2: Console.WriteLine("Second"); break; } }; switchCode(); switchCode(); In the console