471,605 Members | 1,382 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

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

How to expose an enum

Ant
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

Nov 29 '05 #1
3 3347
>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

Nov 29 '05 #2
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

"Ant" wrote:
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

Nov 29 '05 #3
Ant
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

"Truong Hong Thi" wrote:
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

Nov 29 '05 #4

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

21 posts views Thread by Andreas Huber | last post: by
2 posts views Thread by Gerard Stafleu | last post: by
4 posts views Thread by Ohad Redlich | last post: by
34 posts views Thread by Steven Nagy | last post: by
reply views Thread by John Smith | last post: by
reply views Thread by John Smith | last post: by
1 post views Thread by =?Utf-8?B?cHJlZGF0b3Jzdw==?= | last post: by
reply views Thread by MichaelMortimer | last post: by
reply views Thread by CCCYYYY | last post: by

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.