Recently, I needed (yes, I need) to define absurdly long switch and enum expressions in C # code, but I wonder what people think is the best way to break them down into logical subparts. In my situation, both enumeration values ββand cases (which are based on enumeration values) have fairly clear groupings, but I'm not sure how to reflect this in the code.
Please note that in my code I have about 5 groups of 10 and 30 values ββ/ enumeration cases each.
Three vaguely reasonable options that I can foresee are as follows:
- Define
#region blocks all logical groups of case / enum values ββin the declaration (optionally separated by blank lines). - Comment on each group with this name with an empty line before commenting on the group name.
- Do nothing - just leave the / enum switch as a huge list of cases / values.
What do you prefer? Could you separately consider the listings and switches? (This would seem a little strange to me.) Now I would not say that there is a right / wrong answer to this question, although I would still be very interested in learning what the general concept of views is.
Note 1: This situation, when I can potentially have an extremely long declaration of an enumeration of 50/100 + values, is unfortunately inevitable (and similarly with a switch), as I try to write a tokeniser, and this seems to be the most reasonable way approach for several reasons.
Note 2: I am fully aware that there are already several recurring questions about whether to use regions in a common code (for structuring classes mainly), but I feel that my question here is much more specific and has not been addressed yet.
enums c # switch-statement
Noldorin
source share