Define enums within a method in C#?
问题 I have mainly a C++ background and I am learning C#. So, I need some help with C# idioms and style. I am trying to write, in C#, a small text-file parsing method in which I need a simple state variable with three states. In C++ I would declare an enum like this for the state variable: enum { stHeader, stBody, stFooter} state = stBody; ...and then use it in my parsing loop like this: if (state == stHeader && input == ".endheader") { state = stBody; } In C# I realize that it is not possible to