473,378 Members | 1,346 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,378 software developers and data experts.

Using enums in parameters

Suppose I have this enum

public class Flag
{
Hazardous = 1,
Protected = 2
}

and I have this webmethod:

[WebMethod]
public void SetFlag (Flag newFlag)
{
}

WSDL from this will be:

<s:element name="SetFlag">
- <s:complexType>
- <s:sequence>
<s:element minOccurs="1" maxOccurs="1" name="newFlag" type="tns:Flag" />
</s:sequence>

<s:simpleType name="Flag">
- <s:restriction base="s:string">
<s:enumeration value="Hazardous" />
<s:enumeration value="Protected" />
</s:restriction>
</s:simpleType>

which means that client has to pass the enum name ("Hazardous").

However, I would like to pass value (1, 2) and not the name.

Of course, I can change the method to "int newFlag" but then a client can
pass anything..

Can I have enums but pass int?

Thanks,

-Stan
Nov 23 '05 #1
2 1474
I think this defeats a major purpose of Enum from the client's and
developer's perspective. Nobody should care about the value of the
Enum. The Enum value for a specific enumeration could change 1000 times
and nobody should or would care.
Is there a specific reason why one would want to do this?

Nov 23 '05 #2
I want the client to use enum, but pass its value and not the name. In case
of regular class with enum:

SetFlage (Flag.Hazardous)

Flag.Hazardous gets converted to its value
"re****@community.nospam" <ma**********@gmail.com> wrote in message
news:11**********************@o13g2000cwo.googlegr oups.com...
I think this defeats a major purpose of Enum from the client's and
developer's perspective. Nobody should care about the value of the
Enum. The Enum value for a specific enumeration could change 1000 times
and nobody should or would care.
Is there a specific reason why one would want to do this?

Nov 23 '05 #3

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...
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...
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: Matt | last post by:
I have a module I have written that I'd like to use in a number of projets. To save the various users having to tweak the code and recompile it, I'd like to store all the parameters in the...
37
by: mdh | last post by:
In one of the answers to a K&R exercise, the first couple of lines are: enum loop { NO, YES}; enum loop okloop=YES; I get the first line, but not the second. Sorry about the LOL question. ...
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,...
2
by: olympus_mons | last post by:
Hi, I'm just discovering the power of xsd.exe, so maybe I'm doing something wrong. schema files describing requests and responses. So there is an extra xsd file for each response and each...
4
by: zdravko.monov | last post by:
Hi! I am trying to get several parameters in functions as enum variables. Consider this: namespace Layout { enum type { DOT, NEATO, FDP, TWOPI, CIRCO };
7
by: =?Utf-8?B?UGFvbG8=?= | last post by:
I have the following: void setColours() { Console.BackgroundColor = ConsoleColor .Black; Console.ForegroundColor = ConsoleColor.Yellow; } thus setting the colours at compile time.
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
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: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
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
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...

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.