I have a Utils unit in my app which, as of right now, only has a few enums defined, such as:
public enum MostFavoredStates
{
California,
NorthCarolina,
Vermont,
NewMexico
}
public enum LeastFavoredStates
{
NorthDakota,
Illinois,
Nebraska
}
public enum StatesInWhichIHaveResided
{
California,
NewYork,
Montana,
Alaska,
Oklahoma,
Wisconsin,
Idaho,
Missouri
}
When I run ReSharper on my project, it says I need no “using” statements at all in this class; so, I remove them all, and voila! it really does need nothing at all.
“enum” must be declared somewhere – how can it live without a reference to that assembly or namespace? If there’s something “baked in” to every class, what is it?
“enum” is a C# language keyword. It is not a framework type that needs to be resolved, as it’s part of the language itself.
Note that there are many other language keywords that are this way. For example, you can use
intwithout a using clause forusing System;, as it’s “baked into” the language as an alias toSystem.Int32– but you can’t useInt32, since that isSystem.Int32.