How to expose an enum

G

Guest

Hi,
Im wrapping a MailMessage object & need to expose the Priority property.
This property is set to a value of the 'MailPriority' enum. My question is,
how do I create a member that accepts this enum as a value?

as a field named Priority:

public MailPriority Priority; //doesn't work

So that I can set it from the Email instance like this:

myEmail.Priority = MailPriority.High;

Any suggestions would be most appreciated

Ant
 
T

Truong Hong Thi

public MailPriority Priority; //doesn't work
Why not? What is the complaint?
It should work. You could defined a public property also:
private MailPriority priority
public Priority
{
get {return priority; }
set {priority = value; }
}

If it does not work, pls post the error message.

Thi - http://thith.blogspot.com
 
G

Guest

Have you define the enum type called MailPriority ??
e.g.
public enum MailPriority
{
High = 1,
Low = 2
};

if you define the enum type in other class .. remember to set a reference to
that class.

Hope it helps,
Ivan Wong
 
G

Guest

Sorry, my mistake,
I was using it in another class & had forgotten to add the 'using
System.Web.Mail' declaritive in that class. It works fine now.

Thanks for helping out though.
Ant
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top