enumeration question

  • Thread starter Thread starter jamie
  • Start date Start date
J

jamie

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(DataType="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(Namespace="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.
 
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
 
Back
Top