473,405 Members | 2,187 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,405 software developers and data experts.

enumeration question

I almost never use enumerations.

I've been given a class by using XSD /c on a schema file. This will be
used to generate an XML file

It gives me back lots of classes Anyways one of those classes is
public class Transmit{

[System.Xml.Serialization.XmlElementAttribute(DataT ype="integer")]

public string Count;
public TransmitType Type;
public string Creator;

}

Now I've been creating a constructor to put the correct values in for count
and create but I don't know how to handle Type.

TransmitType is

[System.Xml.Serialization.XmlTypeAttribute(Namespac e="gov.bc.ca/forests/hbs/v2")]

public enum TransmitType {

P,

T,
}

P for production T for testing. How do I specify that TransmitType is T
in the constructor fro Transmit? If I do nothing with Type I get back a P
which makes sence since I think enumerations start at 0 and count up. I
can't say Type = "T" or 1 though to get back the T I want.


Mar 21 '06 #1
2 1282
Nevermind Type = TransmitType.T works and I think is the way to go.
"jamie" <st*********@nospam.nospam> wrote in message
news:ev*************@TK2MSFTNGP11.phx.gbl...
I almost never use enumerations.

I've been given a class by using XSD /c on a schema file. This will be
used to generate an XML file

It gives me back lots of classes Anyways one of those classes is
public class Transmit{

[System.Xml.Serialization.XmlElementAttribute(DataT ype="integer")]

public string Count;
public TransmitType Type;
public string Creator;

}

Now I've been creating a constructor to put the correct values in for
count and create but I don't know how to handle Type.

TransmitType is

[System.Xml.Serialization.XmlTypeAttribute(Namespac e="gov.bc.ca/forests/hbs/v2")]

public enum TransmitType {

P,

T,
}

P for production T for testing. How do I specify that TransmitType is T
in the constructor fro Transmit? If I do nothing with Type I get back a
P which makes sence since I think enumerations start at 0 and count up. I
can't say Type = "T" or 1 though to get back the T I want.


Mar 21 '06 #2
> Now I've been creating a constructor to put the correct values in for
count and create but I don't know how to handle Type.


I'm not sure I understand your problem. You you please show more code.
Here is an example on how to use emuns with a class constructor.

using System;
using System.Collections.Generic;
using System.Text;

namespace Enum
{
public enum TransmitType { T = 0, P }

public class Transmit
{
public TransmitType _choosen;
public Transmit(TransmitType t)
{
this._choosen = t;
}
}

class Program
{
public Program()
{
Transmit Obj = new Transmit(TransmitType.P);
System.Console.WriteLine("" + Obj._choosen);
System.Console.ReadKey();
}

static void Main(string[] args)
{
new Program();
}
}
}

Regards,
Lars-Inge Tønnessen
Mar 21 '06 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Justin Wright | last post by:
I know that I can set up an enumeration as follows ( just typed in quick so may have syntax errors ): <xsd:simpleType name="colors"> <xsd:restriction base="xsd:string"> <xsd:enumeration...
8
by: aevans1108 | last post by:
Greetings I can't seem to inherit enumerated values from a globally defined type in my XML schema. XmlSchema.Compile() doesn't like it. Here's the schema. <?xml version="1.0"...
2
by: Mark | last post by:
Assume you have an enumeration like PhoneType { Home, Business, Cell }. This enumeration corresponds with a lookup/dictionary table in your database like: phone_cd | phone_descr 1 ...
4
by: Marshal | last post by:
Sure... IEnumerable was inconvenient suggesting a separate class to service the enumeration, IEnumerator, and multiple operations: Current, MoveNext, Reset. (I'll warp the definition of "operation"...
3
by: Sampson | last post by:
I have a question about enumeration and how to populate them during runtime. I am using vb.net but will happily take any advice in c# as well. Here is an example to help illustrate what I am...
27
by: Ben Finney | last post by:
Antoon Pardon wrote: > I just downloaded your enum module for python > and played a bit with it. IMO some of the behaviour makes it less > usefull. Feedback is appreciated. I'm hoping to...
3
by: Davidoff | last post by:
Hi, I parse an XML file with a XSD schema. One XmlNode has an attribute whose type is a restriction of xs:string : <xs:simpleType name="stypeDay"> <xs:restriction base="xs:string">...
3
by: aarklon | last post by:
Hi all, in the article http://www.c-faq.com/struct/enumvsdefine.html it is written as Some advantages of enumerations are that the numeric values are automatically assigned, that a debugger...
0
by: news.emn.fr | last post by:
Hello, i got this attribute <xs:attribute name="jour"> <xs:simpleType> <xs:restriction base="stypeJour"> </xs:restriction> </xs:simpleType> </xs:attribute>
6
by: Jan Sneeuwman | last post by:
Hello, I am working on a library in C++, and the library goes with a header file with a trailing comma at the end of some enumeration. Like this: enum Abc { ENUM_ONE, ENUM_TWO ENUM_THREE,...
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: 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...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 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 a new...

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.