Forum Discussion

guruprasadgm06_1's avatar
guruprasadgm06_1
Occasional Contributor
12 years ago

how to create dynamic array in C # script

how to create dynamic array in C # script?
  • Philip_Baird's avatar
    Philip_Baird
    Community Expert
    Hi Guruprasad, as C# Script is based on JScript, Arrays are inherently dynamic and you can use the Array::push() method to dynamically increase the Array size as follows:




    function test001() {


      var x = []; // Declare empty Array


      


      x.push( "abc" ); // Push new item, Array will "dynamically" grow


      


      Log["Message"]( x[ 0 ] ); // Logs abc


    }



    Hope this helps, regards,

    Phil Baird
  • Philip_Baird's avatar
    Philip_Baird
    Community Expert
    Hi Guruprasad, if you are writing C# Script for it's intended pupose of  exporting the code to C# Self-Testing and/or Connected Applications you will probably want to disregard my previous post as JScript Arrays are not supported.



    Apologies for any inconvinience