Array.exists(Int32) Method
Definition
Important
Some information relates to prerelease product that may be substantially modified before it’s released. Microsoft makes no warranties, express or implied, with respect to the information provided here.
Determines whether a particular array element is valid.
public:
bool exists(int _index);
public bool exists (int _index);
member this.exists : int -> bool
Public Function exists (_index As Integer) As Boolean
Parameters
- _index
- Int32
The array element to test.
Returns
true if the array element that is pointed to by the index is valid; otherwise, false.
Remarks
The following example uses the exists method to test whether various elements in an array are valid.
{
array a = new array(types::Integer);
a.value(1, 23);
print a.value(1);
pause;
if (a.exists(7)) // No, only element 1 is initialized
{
print a.value(7);
}
else
{
print "Value does not exist";
}
pause;
//Array positions 2 to 9 padded with default values
a.value(10, 55);
if (a.exists(7)) // Yes, elements 1..10 now initialized
{
print a.value(7);
}
else
{
print "Value does not exist";
}
pause;
}