次の方法で共有


Working with System.Char in X++

There are situations where it is useful to workl with characters in X++. As you know, X++ does not have the concept of characters in the defined in the language: Only strings are defined. However, it is not impossible to work with characters in X++, if you use the managed System.Char type. It will not win any prizes for elegance, but it works...

Consider the following example:

static void CharArray(Args _args)
{
    System.Char[] chars;
    System.Char a, b;

    a = System.Char::Parse('a');
    b = System.Char::Parse('b');

    chars = new System.Char[2]();

    chars.SetValue(a, 0);
    chars.SetValue(b, 1);
}

Here an array containing to chars is created, and assigned the values {'a', 'b'}. Note the special trick used to create a character literal, using the System.Char::Parse method.