literals
This is an old revision of the document!
Table of Contents
Literals, prefixes and suffixes
String literals
A string literal is delimited with the double hyphen “.
"This is a string"
Please note that in the VO dialect a string can also be delimited with the single hyphen ' .
'This is a string' // valid only in the VO dialect, not in Core or Vulcan
If you need to specify special characters or single hyphens in a string, you need an escaped string, prefixed with e:
e"This is an escaped string with a new line \nand a double \" hyphen"
There are also interpolated strings that can contain variables:
local cValue := "guys" as string
Console.WriteLine( i"Hi {cValue}" ) // Hi guys
For more details please see Strings and their prefixes and String, Char and Byte
Numeric literals
As default, every number with decimals is treated as Double datatype, and every number without decimals as Int32 datatype.
If you need to specify what type a numeric literal should take, use suffixes:
dfor Doublesfor Ssinglemfor Decimalbfor Binary
You can also use a prefix of 0x to specify a hexadecimal value.
Sample code:
Console.WriteLine( "123.45 is a " + (123.45 ):GetType():Name ) // Double Console.WriteLine( "123 is a " + (123 ):GetType():Name ) // Int32 Console.WriteLine( "123s is a " + ( 123s ):GetType():Name ) // Single Console.WriteLine( "123d is a " + ( 123d ):GetType():Name ) // Double Console.WriteLine( "123dm is a " + ( 123m ):GetType():Name ) // Decimal Console.WriteLine( "0x111 has a decimal value of " + 0x111:ToString() ) // decimal 273 Console.WriteLine( "0b111 has a decimal value of " + 0b111:ToString() ) // decimal 7
literals.1518250514.txt.gz · Last modified: 2018/02/10 08:15 by wolfgangriedmann