Convert to string an enum item

2015-12-23 Thread tcak via Digitalmars-d-learn
[code] import std.stdio; import std.conv; enum Values: ubyte{ One = 1, Two = 2 } void main(){ writeln( std.conv.to!string( Values.One ) ); } [/code] Output is "One". casting works, but to be able to cast correctly, I need to tell compiler that it is "ubyte". Isn't there any

Re: Convert to string an enum item

2015-12-23 Thread Alex Parrill via Digitalmars-d-learn
On Wednesday, 23 December 2015 at 13:11:28 UTC, tcak wrote: [code] import std.stdio; import std.conv; enum Values: ubyte{ One = 1, Two = 2 } void main(){ writeln( std.conv.to!string( Values.One ) ); } [/code] Output is "One". casting works, but to be able to cast correctly, I need to

Re: Convert to string an enum item

2015-12-23 Thread Meta via Digitalmars-d-learn
On Wednesday, 23 December 2015 at 17:43:52 UTC, Alex Parrill wrote: On Wednesday, 23 December 2015 at 13:11:28 UTC, tcak wrote: [code] import std.stdio; import std.conv; enum Values: ubyte{ One = 1, Two = 2 } void main(){ writeln( std.conv.to!string( Values.One ) ); } [/code] Output

Re: Convert to string an enum item

2015-12-23 Thread Meta via Digitalmars-d-learn
On Wednesday, 23 December 2015 at 17:43:52 UTC, Alex Parrill wrote: On Wednesday, 23 December 2015 at 13:11:28 UTC, tcak wrote: [code] import std.stdio; import std.conv; enum Values: ubyte{ One = 1, Two = 2 } void main(){ writeln( std.conv.to!string( Values.One ) ); } [/code] Output