casting_astype
no way to compare when less than two revisions
Differences
This shows you the differences between two versions of the page.
— | casting_astype [2018/04/22 09:45] (current) – created wolfgangriedmann | ||
---|---|---|---|
Line 1: | Line 1: | ||
+ | .NET and X# permit an enhanced casting of variables. Using the casting the compiler can will check the properties and methods of the object. | ||
+ | < | ||
+ | local oDateTime as object | ||
+ | |||
+ | oObject := DateTime.Now | ||
+ | oObject: | ||
+ | ( ( DateTime ) oObject ):AddYears( 1 ) // works | ||
+ | oDateTime := oObject // compiler error here | ||
+ | oDateTime := ( DateTime ) oObject // | ||
+ | |||
+ | The '' | ||
+ | < | ||
+ | In the case that oObject is not a string, the null value is assigned to the oString variable. | ||
+ | The following code will not work as '' | ||
+ | < | ||
+ | |||
+ | oDateTime := oObject astype DateTime</ | ||
+ | This code will only work if you use '' | ||
+ | |||
+ | |||
casting_astype.txt · Last modified: 2018/04/22 09:45 by wolfgangriedmann