Type Conversion and Creation

  • Updated

Note that these APIs exist principally for CLR interop purposes; they are generally unnecessary for use inside irScript proper, where implicit type conversions are performed by the language itself, as needed.

Method Name Return type Arguments Description
ToGuid
System.Guid
element
Creates a new guid from the supplied Text value element
ToEnum <varies> fullyQualifiedEnum TypeName, textualEnumValue Creates a new System.Enum- subclassed value corresponding to the specified type name (CLR namespace+type) and textual value representation
IsNativeInteger Boolean element Returns true if element is a 64-bit signed integer, otherwise false
IsNativeDecimal Boolean element Returns true if element is a System.Decimal value, otherwise false
IsNativeCollection Boolean element Returns true if element is a native irScript ScriptCollection, otherwise false
CreateDictionary System.IDictiona ry<string, object> <none> Creates and returns a new, empty CLR dictionary
ToArray System.Array of designated type collection, elementType Creates a new CLR array with elements of type elementType and copies the elements of collection into it; all elements must be of type elementType or subclasses of elementType
ToArrayWithTran sform System.Array of designated type collection, elementType, transformFunction Creates a new CLR array with elements of type elementType and copies the elements of collection into it; transformFunction is a ScriptFunction taking one parameter and returning a value; transformFunction is invoked for each element prior to copying, and the result for each element must be of type elementType or a subclass of elementType
ToCollection ScriptCollection collection Creates a new ScriptCollection by copying all elements from collection (any System.IEnumerable instance)
ToInt Integer Any Converts argument value to an intrinsic integer value
ToNumber Decimal Any Converts argument value to an intrinsic decimal value
ToString Text Any Converts argument value to an intrinsic string value
ToBool Boolean Any Converts argument value to an intrinsic boolean value
ToDateTime DateTime Any Converts argument value to an intrinsic datetime value
ToDate Date Any Converts argument value to an intrinsic date value
New CLR object type Assembly-qualified CLR type name, optional constructor arguments Creates an instance of the type specified by the first argument (type name), by invoking the constructor that matches the other specified arguments (if none, then invokes default constructor)

Was this article helpful?

0 out of 0 found this helpful

Comments

0 comments

Please sign in to leave a comment.