As others have pointed out, a property is โcloserโ than a type, so when a simple name is resolved, the property always wins.
An interesting wrinkle in this situation is that if you made a property of type CostType and not int, it would work.
The reason for this is that C # has a special rule only for this situation, usually called the "Color Color" rule. (Because the situation most often arises: the type Color and the property Color of Color).
If a simple name can mean both a type and a property or field with that name, then C # allows you to access static members through type and instance members through a property. This allows you to do things like:
Color = Color.Red; description = Color.ToString();
The first and third colors are property references; the second is a type reference.
source share