Click or drag to resize

ArraySwapT Function (Array OfT, UInt32, T)

Replace an array element with a new value and return the old value.

Namespace:  XSharp.RT
Assembly:  XSharp.RT (in XSharp.RT.dll) Version: 2.10
Syntax
 FUNCTION ArraySwap<T>(
	aTarget AS ARRAY OF<T>,
	dwElement AS DWORD,
	uNewValue AS T
)
WHERE T : NEW()
 AS T
View Source

Parameters

aTarget
Type: Array OfT
The array whose element will be replaced with a new value.
dwElement
Type: UInt32
The number of the element to be replaced.
uNewValue
Type: T
The new value.

Type Parameters

T
The type of the array elements

Return Value

Type: T
The value that was replaced by <uNewValue>.
Remarks
ArraySwap() replaces the element specified with a new value.
Examples
This example swaps the second and third elements of an array:
X#
FUNCTION Start()
        LOCAL aList[4]
        ArrayPut(aList, 1, "First")
        ArrayPut(aList, 2, "Second")
        ArrayPut(aList, 3, "Third")
        ArrayPut(aList, 4, "Fourth")
        aList[3] := ArraySwap(aList, 2, aList[3])
See Also