How to call a Hub Method with Array or ListTypes

To assign to property that takes a list or an array (or any collection), Tresi, provides 2 ways.  You can choose whichever is most convenient for you.  Let's take for example the below User class.  It has property "Friends" which is a list of users (List<User>).

If we wanted to assign 2 instances of the User class to the Friends property we could do the following

Option 1 : Assigning a value using the [ ]

First we manually create 2 instances, "friend1" and "friend2" and then assign these 2 to the Friends property by putting it inside a square bracket "[]", as per the screenshot below



(Click to enlarge)

 

Option 2 : Assigning a value using the "Item(index)" function

Another way to create a list is to automatically build it up by calling the Item function.  The first item in the list always begins at index 0, the 2nd item is at index 1, the 3rd at index 2, and so on.  This approach is shown in the screenshot below

(Click to enlarge)

 


Site Map | Printable View | © 2008 - 2018 WCFStorm Solutions

Powered by mojoPortal | XHTML 1.0 | CSS | Design by styleshout