Here is the code again:
http://www.geocities.com/jeff_louie/OOP/oop5.htm
sealed class MyEnum
{
*** private String name;
*** private static int nextOrdinal= 1;
*** private int ordinal= nextOrdinal++;
*** private MyEnum(String name)
*** {
******* this.name= name;
*** }
*** public override String ToString()
*** {
******* return name;
*** }
*** public int ToOrdinal()
*** {
******* return ordinal;
*** }
*** public static MyEnum INVALID= new MyEnum("Invalid "); // ordinal 1
*** public static MyEnum OPENED= new MyEnum("Opened" ); // ordinal 2
*** public static MyEnum CLOSED=new MyEnum("Closed" ); // ordinal 3
*** /// <summary>
*** /// The main entry point for the application.
*** /// </summary>
*** [STAThread]
*** static void Main(string[] args)
*** {
******* //
******* // TODO: Add code to start application here
******* //
******* Console.WriteLi ne(MyEnum.OPENE D.ToString());
******* Console.WriteLi ne(MyEnum.OPENE D.ToOrdinal().T oString());
******* Console.WriteLi ne(MyEnum.INVAL ID.ToString());
******* Console.WriteLi ne(MyEnum.INVAL ID.ToOrdinal(). ToString());
******* Console.WriteLi ne(MyEnum.CLOSE D.ToString());
******* Console.WriteLi ne(MyEnum.CLOSE D.ToOrdinal().T oString());
******* Console.ReadLin e();
*** }
}
Regards,
Jeff
Is it possible to override the ToString() method when
creating a simple enumeration?<
*** Sent via Developersdex
http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!