www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.announce - getting the string representing the enum value

reply Hasan Aljudy <hasan.aljudy gmail.com> writes:
say I have an enum

	enum X
	{
	 A,
	 B,
	 C
	}

and I have

	void someFunc( X e )
	{
	 //.. some code
	}

I want to print the value of 'e' but I don't want to get a number!! I 
want to get a string that represents it. i.e. A or B or C


	void someFunc( X e )
	{
	   toString(e);
	   e.string;
	   e.value;
	   //or something like that ..
	}

Is there any such thing in D?
Apr 01 2006
parent Hasan Aljudy <hasan.aljudy gmail.com> writes:
Woops, I keep posting in the wrong section, sorry just ignore this. :(

Hasan Aljudy wrote:
 say I have an enum
 
     enum X
     {
      A,
      B,
      C
     }
 
 and I have
 
     void someFunc( X e )
     {
      //.. some code
     }
 
 I want to print the value of 'e' but I don't want to get a number!! I 
 want to get a string that represents it. i.e. A or B or C
 
 
     void someFunc( X e )
     {
        toString(e);
        e.string;
        e.value;
        //or something like that ..
     }
 
 Is there any such thing in D?
 

Apr 01 2006