String in X++ Programming Language

Rumman Ansari   Software Engineer   2023-10-25   7872 Share
☰ Table of Contents

Table of Content:


Strings are sequences of characters that are used as texts, help lines, addresses, telephone numbers, and so on. To declare a string in X++, use the str keyword.

A string can hold an indefinite number of characters. If you know the absolute maximum of characters a string will hold, you can specify this in the variable declaration and force a truncation to the maximum length of the string.

 

String Literals

String literals are characters that are enclosed in quotation marks (" ") and can be used where string expressions are expected. Here are some examples:

  • "Nothing"

  • "A"

  • "yiruyshfkjsadhfkasfhksafhask"

  • "Press any key now."

If you want the string to span more than one line, you need to precede it with an "@" character. For example:

str s = @"This is a very long string that may not fit onto a single line and so may span more than one line";

 

Overview of Strings

Keyword

str

Size of data type

Dynamic or fixed length

Scope of data type

Unlimited

Default value

"" (empty)

Implicit conversions

None

Explicit conversions

str2int, str2int64, int2str, str2num, num2str, str2date, date2str