Does D has C#'s string.Empty?

Steven Schveighoffer via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Thu Sep 25 05:43:57 PDT 2014


On 9/25/14 2:41 AM, SlomoTheBrave wrote:
> On Thursday, 25 September 2014 at 05:29:37 UTC, AsmMan wrote:
>> Does D has C#'s string.Empty?
>
> string.init ?
>
> ----
>      string a;
>      a = string.init;
>      assert( a == "");
> ----
>
> does the job for the type string at least.
>
null also works. In fact, in the above, a is already string.init or null 
before assigning (D always initializes variables unless asked not to).

a = null; // same as a = string.init;

-Steve


More information about the Digitalmars-d-learn mailing list