Note: This website is archived. For up-to-date information about D projects and development, please visit

Declaring Variables

Part of TutorialFundamentals

In order to store information within a D program, you must declare variables before they are used. The syntax is name_of_type identifier.

void main()
    int myInteger;
    double myDouble;
    bool myBit;
    string myString;

D1.x vs D2.x

In version 1 of D, 'string' is an alias for 'char[]' and in version 2 'string' is an alias for 'immutable(char)[]'.