ICollection.ToArray 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.
Overloads
ToArray() |
Returns an array containing all of the elements in this collection. |
ToArray(Object[]) |
Returns an array containing all of the elements in this collection; the runtime type of the returned array is that of the specified array. |
ToArray(IIntFunction) |
Returns an array containing all of the elements in this collection,
using the provided |
ToArray()
Returns an array containing all of the elements in this collection.
[Android.Runtime.Register("toArray", "()[Ljava/lang/Object;", "GetToArrayHandler:Java.Util.ICollectionInvoker, Mono.Android, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null")]
public Java.Lang.Object[] ToArray ();
[<Android.Runtime.Register("toArray", "()[Ljava/lang/Object;", "GetToArrayHandler:Java.Util.ICollectionInvoker, Mono.Android, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null")>]
abstract member ToArray : unit -> Java.Lang.Object[]
Returns
an array, whose Class#getComponentType runtime component
type is Object
, containing all of the elements in this collection
- Attributes
Remarks
Returns an array containing all of the elements in this collection. If this collection makes any guarantees as to what order its elements are returned by its iterator, this method must return the elements in the same order. The returned array's Class#getComponentType runtime component type is Object
.
The returned array will be "safe" in that no references to it are maintained by this collection. (In other words, this method must allocate a new array even if this collection is backed by an array). The caller is thus free to modify the returned array.
Java documentation for java.util.Collection.toArray()
.
Portions of this page are modifications based on work created and shared by the Android Open Source Project and used according to terms described in the Creative Commons 2.5 Attribution License.
Applies to
ToArray(Object[])
Returns an array containing all of the elements in this collection; the runtime type of the returned array is that of the specified array.
[Android.Runtime.Register("toArray", "([Ljava/lang/Object;)[Ljava/lang/Object;", "GetToArray_arrayLjava_lang_Object_Handler:Java.Util.ICollectionInvoker, Mono.Android, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null")]
[Java.Interop.JavaTypeParameters(new System.String[] { "T" })]
public Java.Lang.Object[] ToArray (Java.Lang.Object[] a);
[<Android.Runtime.Register("toArray", "([Ljava/lang/Object;)[Ljava/lang/Object;", "GetToArray_arrayLjava_lang_Object_Handler:Java.Util.ICollectionInvoker, Mono.Android, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null")>]
[<Java.Interop.JavaTypeParameters(new System.String[] { "T" })>]
abstract member ToArray : Java.Lang.Object[] -> Java.Lang.Object[]
Parameters
- a
- Object[]
the array into which the elements of this collection are to be stored, if it is big enough; otherwise, a new array of the same runtime type is allocated for this purpose.
Returns
an array containing all of the elements in this collection
- Attributes
Remarks
Returns an array containing all of the elements in this collection; the runtime type of the returned array is that of the specified array. If the collection fits in the specified array, it is returned therein. Otherwise, a new array is allocated with the runtime type of the specified array and the size of this collection.
If this collection fits in the specified array with room to spare (i.e., the array has more elements than this collection), the element in the array immediately following the end of the collection is set to null
. (This is useful in determining the length of this collection only if the caller knows that this collection does not contain any null
elements.)
If this collection makes any guarantees as to what order its elements are returned by its iterator, this method must return the elements in the same order.
Java documentation for java.util.Collection.toArray(T[])
.
Portions of this page are modifications based on work created and shared by the Android Open Source Project and used according to terms described in the Creative Commons 2.5 Attribution License.
Applies to
ToArray(IIntFunction)
Returns an array containing all of the elements in this collection,
using the provided generator
function to allocate the returned array.
[Android.Runtime.Register("toArray", "(Ljava/util/function/IntFunction;)[Ljava/lang/Object;", "GetToArray_Ljava_util_function_IntFunction_Handler:Java.Util.ICollection, Mono.Android, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null", ApiSince=33)]
[Java.Interop.JavaTypeParameters(new System.String[] { "T" })]
public virtual Java.Lang.Object[] ToArray (Java.Util.Functions.IIntFunction generator);
[<Android.Runtime.Register("toArray", "(Ljava/util/function/IntFunction;)[Ljava/lang/Object;", "GetToArray_Ljava_util_function_IntFunction_Handler:Java.Util.ICollection, Mono.Android, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null", ApiSince=33)>]
[<Java.Interop.JavaTypeParameters(new System.String[] { "T" })>]
abstract member ToArray : Java.Util.Functions.IIntFunction -> Java.Lang.Object[]
override this.ToArray : Java.Util.Functions.IIntFunction -> Java.Lang.Object[]
Parameters
- generator
- IIntFunction
a function which produces a new array of the desired type and the provided length
Returns
an array containing all of the elements in this collection
- Attributes
Remarks
Returns an array containing all of the elements in this collection, using the provided generator
function to allocate the returned array.
If this collection makes any guarantees as to what order its elements are returned by its iterator, this method must return the elements in the same order.
Added in 11.
Java documentation for java.util.Collection.toArray(java.util.function.IntFunction<T[]>)
.
Portions of this page are modifications based on work created and shared by the Android Open Source Project and used according to terms described in the Creative Commons 2.5 Attribution License.