Westwind.WebConnection.wwDotNetBridge.SetArrayItem C# (CSharp) Method

SetArrayItem() public method

Sets an array element to a given value. Assumes the array is big enough and the array item exists.
public SetArrayItem ( object baseObject, string arrayName, int index, object value ) : bool
baseObject object base object reference
arrayName string Name of the array as a string
index int The index of the item to set
value object The value to set the array item to
return bool
        public bool SetArrayItem(object baseObject, string arrayName, int index, object value)
        {
            SetError();

            Array ar = baseObject.GetType().InvokeMember(arrayName,
                                  BindingFlags.Instance | BindingFlags.Public | BindingFlags.GetProperty | BindingFlags.GetField,
                                   null, baseObject, null) as Array;

            // *** Null assignments are not allowed because we may have to create the array
            // *** and a type is required for that. If necessary create an empty instance
            if (ar == null)
                return false;

            ar.SetValue(value, index);

            return true;
        }
wwDotNetBridge