How can I use hex value into enum?

In reply to yourcheers:

$size(colors) gives you the number of array elements, 8, which is the same as $bits(Colors) in this case. Colors.num gives the number of enumerations.

You could also use a do-while loop

module enum_datatype;
  typedef enum bit[7:0] { red=8'h2, green, blue=8'h4, yellow, white=8'h10, black } Colors;
   Colors Color;
   
   //display members of Colors
   initial begin
      Color = Color.first;
      do begin
	 $display("Colors :: Value of  %0s \t is = %0d and Size is %d",Color.name,Color, $bits(Color));
	 Color = Color.next;      
      end while(Color != Color.first);
  end
endmodule