473,387 Members | 1,374 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

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 1373
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

13
by: SpaceCowboy | last post by:
I recently got into a discussion with a co-worker about using enums across a dll interface. He wanted to use chars instead, argueing that depending on compiler settings the size of an enum could...
2
by: Faisal | last post by:
Can anyone tell me if it is possible to enumerate through all the Enums within a class . I have a class with many Enums and would like to accees the Enums through an array/collection etc. I can't...
27
by: Mark A. Gibbs | last post by:
i have been toying with the idea of making my enums smarter - ie, more in line with the rest of the language. i haven't tested it yet, but what i came up with is a template like this: template...
3
by: zaphod | last post by:
I want to use MS Accesss as a front end for an existing MySQL database. Since Acceess doesn't have the same data types, eg. ENUM, am I tied to the smaller subset of types supported by Access? I'm...
2
by: SpotNet | last post by:
Hello CSharpies, Can Enums in C# be UInt32 Types, and not just Int32 Types. I have a lot of constant declarations that are UInt32 that I want to put in Enums to ease the use of Intellisence. I...
7
by: narshe | last post by:
I haven't come across an elegant way to do this yet, and would like to know what other people have come up with. There are two tables: CREATE TABLE EmployeeStatus ( pkId int not null primary...
4
by: Martin Pritchard | last post by:
Hi, I'm working on a project that historically contains around 40 enums. In the database various fields refer to the int values of these enums, but of course ref integrity is not enofrced and...
2
by: Simon Elliott | last post by:
I have some legacy C++ code which requires some enums to be 1 or 2 bytes in size. I'd ideally like to be able to specify that a few carefully selected enums are a particular size. By default,...
11
by: Marc Gravell | last post by:
This one stumped me while refactoring some code to use generics... Suppose I declare an enum MyEnum {...} Is there a good reason why MyEnum doesn't implement IEquatable<MyEnum> ? Of course,...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.