How to get switch case values

by Lubomir Stoimchev   Last Updated January 11, 2019 09:05 AM

I was wondering if there is a way to get the values of every case in a switch statement? When you provide a not implemented case, I would like to throw some exception and provide a list of available case values.

switch (partName.Trim().ToLower())
    case "engine":
    case "door":
    case "wheel":
        throw new NotImplementedException($"Available parts are {????}.");

Related Questions

Most efficient method for large switch statements

Updated January 26, 2018 11:05 AM

How to use a switch statement with enum efficiently?

Updated November 23, 2017 08:05 AM

Avoiding the `goto` voodoo?

Updated January 21, 2019 23:05 PM