Question about classes and enumerated types
Posted on 2006-06-30
I am writing a program that converts some data to Microsoft Project 2003 XML format. I am writing a class that will allow the ASPX page to fill in properties based on what the user selected on the web page. Some of these properties, like "FYStartDate", which represents Fiscal Year Start month, has acceptable values from January through December. But on the conversion, I need this to be a numeric value. I am unsure how to do this. Here is my current code in the business layer, but it just accepts a numeric value:
public class MSProject2003
private short projectFYStartDate;
public short FYStartDate
projectFYStartDate = value;
Then from the .cs code behind page, this looks like:
MSProject2003 msp = new MSProject2003();
msp.FYStartDate = 3; //This would represent setting it to March.
However, I would want it to look something like this, but i don't know how to code it:
msp.FYStartDate = FYStartMonths.March;
This is an example just showing month. But I have a lot of other types of things that need to be converted into some type of number. I just don't know how to code it. But this seems really clean. Kind of like the ConnectionObject. When you check the state of the Connection it's like:
if(conn.ConnectionState == ConnectionState.Closed)
How do I code the "ConnectionState.Closed" part?
I'm hoping I'm making sense. this is kind of tough to articulate in words. Thanks for the help.