468,768 Members | 1,603 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 468,768 developers. It's quick & easy.

using enums across a web app


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

*** Sent via Developersdex http://www.developersdex.com ***
Mar 14 '06 #1
1 1258
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.

--
-Demetri
"Mike P" wrote:

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

*** Sent via Developersdex http://www.developersdex.com ***

Mar 14 '06 #2

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

13 posts views Thread by SpaceCowboy | last post: by
2 posts views Thread by Faisal | last post: by
27 posts views Thread by Mark A. Gibbs | last post: by
2 posts views Thread by SpotNet | last post: by
7 posts views Thread by narshe | last post: by
4 posts views Thread by Martin Pritchard | last post: by
2 posts views Thread by Simon Elliott | last post: by
11 posts views Thread by Marc Gravell | last post: by
1 post views Thread by CARIGAR | last post: by
reply views Thread by Marin | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.