is a base class for all arrays in C#. Thus, its
methods can be applied to arrays of any of the built-in types or to arrays of types that you
defines the properties shown in Table 21-11. It defines the methods shown in
. The
IComparer
. It defines a method called
the values of two objects. It is shown here:
. It defines a generic form of
and zero if the two values are equal. The advantage to
specified. Thus, no casts from
object
are required.
equivalent. If successful, the value is stored in
is returned. If the string is neither
false if the array is dynamic. This value is true for arrays.
multithreaded environment and false if it is not. This value is
642
P a r t I I :
E x p l o r i n g t h e C # L i b r a r y
public int Length { get; }
An
int
read-only proper ty that contains the number of elements
in the array.
public long LongLength { get; }
A
long
read-only proper ty that contains the number of elements
in the array.
public int Rank { get; }
A read-only proper ty that contains the number of dimensions in
the array.
public object SyncRoot { get; }
A read-only proper ty that contains the object that synchronizes
access to the array.
T
ABLE
21-11
Proper ties Defi ned by
Array
(continued)
Property
Meaning
Method
Meaning
public static ReadOnlyCollection
AsReadOnly(T[ ]
a
)
Returns a read-only collection that wraps the array specified by
a.
public static int Binar ySearch(Array
a
, object
v
)
Searches the array specified by
a
for the value specified by
v.
Returns the
index of the first match. If
v
is not found, returns a negative value. The array
must be sor ted and one-dimensional.
public static int Binar ySearch(T[ ]
a
, T
v
)
Searches the array specified by
a
for the value specified by
v.
Returns the
index of the first match. If
v
is not found, returns a negative value. The array
must be sor ted and one-dimensional.
public static int
Binar ySearch(Array
a
, object
v
,
IComparer
comp
)
Searches the array specified by
a
for the value specified by
v,
using the
comparison method specified by
comp.
Returns the index of the first match.
If
v
is not found, returns a negative value. The array must be sor ted and one-
dimensional.
public static int
Binar ySearch(T[ ]
a
, T
v
,
IComparer
comp
)
Searches the array specified by
a
for the value specified by
v,
using the
comparison method specified by
comp.
Returns the index of the first match.
If
v
is not found, returns a negative value. The array must be sor ted and one-
dimensional.
public static int
Binar ySearch(Array
a
, int
star t
,
int
count
, object
v
)
Searches a por tion of the array specified by
a
for the value specified by
v.
The search begins at the index specified by
star t
and is restricted to
count
elements. Returns the index of the first match. If
v
is not found, returns a
negative value. The array must be sor ted and one-dimensional.
public static int
Binar ySearch(T[ ]
a
, int
star t
,
int
count
, T
v
)
Searches a por tion of the array specified by
a
for the value specified by
v.
The search begins at the index specified by
star t
and is restricted to
count
elements. Returns the index of the first match. If
v
is not found, returns a
negative value. The array must be sor ted and one-dimensional.
public static int
Binar ySearch(Array
a
, int
star t
,
int
count
, object
v
,
IComparer
comp
)
Searches a por tion of the array specified by
a
for the value specified by
v,
using the comparison method specified by
comp.
The search begins at the
index specified by
star t
and is restricted to
count
elements. Returns the
index of the first match. If
v
is not found, returns a negative value. The array
must be sor ted and one-dimensional.
public static int
Binar ySearch(T [ ]
a
, int
star t
,
int
count
, T
v
,
IComparer
comp
)
Searches a por tion of the array specified by
a
for the value specified by
v,
using the comparison method specified by
comp.
The search begins at the
index specified by
star t
and is restricted to
count
elements. Returns the
index of the first match. If
v
is not found, returns a negative value. The array
must be sor ted and one-dimensional.
T
ABLE
21-12
Methods Defi ned by
Array
www.freepdf-books.com