Returns an array item from a .NET array property tied to an object instance.
DO wwDotNetBridge
loBridge = CREATEOBJECT("wwDotNetBridge")
loItem = loBridge.CreateInstance("Westwind.WebConnection.VfpTestClass")
*** Create a new person object
loPerson = loBridge.CreateInstance("Westwind.WebConnection.Person")
loPerson.Name = "Jim johnson"
loPerson.Company = "Temporary traders"
*** Create one element array and set the first slot to loPerson
loBridge.CreateArrayOnInstance(loItem,"PersonArray",loPerson)
*** Retrieve it so we can see it worked
loPerson = loBridge.GetArrayItem(loItem,"PersonArray",0)
? loPerson.Name
? loPerson.Company
Note that this method may not be necesary if you are only reading array/collection values in a read-only fashion. Indexers (object.Array[1]) will work as long as the array isn't updated and if you can use indexers for better performance without overhead of calling back into .NET for retrieving array elements.
This method works on arrays and collections (using indexers) that ordinarily don't work with indexers such as arrays of value types.
o.GetArrayItem(loBaseObject,lcArrayProperty,lnIndex)
Return Value
the object/value
Parameters
loBaseObject
The base object reference on which the array is defined.
lcArrayProperty
The string name of the array property
lnIndex
The index of the item to retrieve as a 0 based value.
Remarks
This method only works on arrays that are properties of another object not on raw array instances. The reason for this is that VFP changes .NET arrays into FoxPro arrays and the .NET type information gets lost in the process resulting in an object that can't be further manipulated or be passed back to .NET easily. Hence only root arrays are supported.
See also:
Class wwDotNetBridge | Accessing Arrays© West Wind Technologies, 2004-2020 • Updated: 03/03/11
Comment or report problem with topic