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":
        //something
        break;
    case "door":
        //something
        break;
    case "wheel":
        //something
        break;
    default:
        throw new NotImplementedException($"Available parts are {????}.");
}


Related Questions


Updated December 10, 2017 02:05 AM

Updated January 26, 2018 11:05 AM

Updated November 23, 2017 08:05 AM