문제

How do I convert a type to a string?

I thought something like this should work

import std.stdio: writeln;
import std.conv: to;
writeln(to!string(int));

Update: I found it at http://dlang.org/phobos/std_traits.html#.fullyQualifiedName

I guess all logic in D operating on types are given as templates arguments right?

도움이 되었습니까?

해결책

  1. int is already a type. You don't need to typeof it.

  2. You could use the .stringof property to get a string representation. http://ideone.com/T4yYmo

    writeln(int.stringof);
    
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top