Forum Discussion

minhterry's avatar
minhterry
Contributor
11 years ago

Working with array in dotNET

Hello,



I have problem with object XXX that i get from dotNET CLR BRIDGE.



It has a property that accep System.String[]

Example: xxx["ChildId"]

So how can i set the value to that property.



I tried: xxx["ChildId"] = {"Alice","Dominate"} , but not success

Please help me.



--

Regards,

MinhT







  • HKosova's avatar
    HKosova
    SmartBear Alumni (Retired)
    Hi MinhT,



    Try one of these:



    Create a .NET array by splitting a string by whitespace:



    Create an array and set values dynamically:

    var arr = dotNET.System.Array.CreateInstance(dotNET.System.String.Empty.GetType(), 2 /* length */);

    arr.SetValue("Alice", 0);

    arr.SetValue("Dominate", 1);
  • Hello Helen Kosova,



    The first is error. But the second works. You save my day.



    --

    Thanks a lot,

    MinhT