I have namespace with enums:
namespace Search
{
enum SearchConditionType
{
Like = 0,
EqualNotString = 1,
EqualString = 2
};
}
Then I try to declare enum:
namespace Search
{
public partial class Controls_SelectYesNo : System.Web.UI.UserControl
{
public SearchConditionType Field;
...
A开发者_开发技巧nd got an error:
The type or namespace name '' could not be found (are you missing a using directive or an assembly reference?)
What is wrong?
enum SearchConditionType
Your enum is not public.
Make the enum public
:
public enum SearchConditionType
{
Like = 0,
EqualNotString = 1,
EqualString = 2
};
Types that do not have an access modifier default to internal
in C#.
If the files are in different assemblies, you need to add a reference to the assembly containingn the enum. This can be done through the References
node of the project in the Solution Explorer.
Hmm... you are attempting to expose an internal type as a public type. That's the only problem I see with your code. But it shouldn't cause the compiler error you're providing, so I'm thinking maybe the problem is elsewhere in your code.
edit: Are you trying to expose the enum in another assembly? That'd cause the error you're listing. So, yeah, just make the enum public.
Problem was in next: I made a web application from web site. In web site enums was situated in App_Code folder. When I rename this folder - problem disappears.
精彩评论