using enums across a web app

M

Mike P

I have an enum that I want to use across my web app. I have a base
class that most of my web pages inherit from that I have put it in, and
a data access class as well. But when I make reference to it in my web
pages I get the error :

'Cannot implicitly convert type 'DataAccess.DBResult' to
'Main.DBResult'. An explicit conversion exists (are you missing a
cast?)'

So I need to cast the return value as a Main.DBResult? Is this the
right way to go about this?

Thanks,

Mike
 
G

Guest

So, it appears you have two different enums (though named the same) nested
within two different classes.

Why not do this:

namespace MyApp{
enum DBResult{
SomeResult,
AnotherResult
}

public class MyBasePage : System.Web.UI.Page{
//You can use DBResult here
}

public class MyDataAccess{
// and you can use DBResult here
}
}

In the above, DBResult is the same type regardless of what class you use it
in.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top