//Is it too early to learn about switch pattern matching? //Only available in C# v8.0 and newer (.Net Core 3.x or .Net 5.0 and newer) Public static double BasicOp(char op, double a, double b) => op switch { '*' => a * b, '+' => a + b, // Other ops _ => 0 }; //*Edit - fixed some syntax errors
Preview:
downloadDownload PNG
downloadDownload JPEG
downloadDownload SVG
Tip: You can change the style, width & colours of the snippet with the inspect tool before clicking Download!
Click to optimize width for Twitter