Share via


RecognitionAlternates.CopyTo Method

Copies all of the elements of the current RecognitionAlternates collection to the specified one-dimensional array, starting at the specified destination array index.

Namespace:  Microsoft.Ink
Assembly:  Microsoft.Ink (in Microsoft.Ink.dll)

Syntax

'Declaration
Public Sub CopyTo ( _
    array As Array, _
    index As Integer _
)
'Usage
Dim instance As RecognitionAlternates 
Dim array As Array 
Dim index As Integer

instance.CopyTo(array, index)
public void CopyTo(
    Array array,
    int index
)
public:
virtual void CopyTo(
    Array^ array, 
    int index
) sealed
public final function CopyTo(
    array : Array, 
    index : int
)

Parameters

  • array
    Type: System.Array

    The one-dimensional array that is the destination of elements copied from the collection. The array must have zero-based indexing.

  • index
    Type: System.Int32

    The zero-based index in the array parameter at which copying begins.

Implements

ICollection.CopyTo(Array, Int32)

Remarks

The elements are copied to the Array object in the same order in which the enumerator iterates through the RecognitionAlternates.

An exception is thrown if:

  • The array parameter is a nulla null reference (Nothing in Visual Basic) (Nothing in Microsoft® Visual Basic® .NET) reference.

  • The index parameter is less than zero.

  • The array parameter is multidimensional.

  • The index parameter is equal to or greater than the length of the array parameter.

  • The number of elements in the collection is higher than the available space from the index parameter to the end of the destination array parameter.

The type of the collection is cast automatically to the type of the destination array parameter. However, this method only copies elements to arrays of the same type as the elements of the collection or arrays of type Object. Attempting to copy to another type of array causes an InvalidCastException exception to be thrown.

This method is synchronized.

Examples

In this example, the CopyTo method is used to fill an array of RecognitionAlternate objects with the entire contents of the RecognitionAlternates collection.

' get the RecognitionAlternates from the RecognitionResult object 
Dim mAlternates As RecognitionAlternates = mRecognitionResult.GetAlternatesFromSelection()
'Create the array to copy alternates into 
Dim theCopies(mAlternates.Count - 1) As RecognitionAlternate
'Copy the alternates to the array
mAlternates.CopyTo(theCopies, 0)
// get the RecognitionAlternates from the RecognitionResult object
RecognitionAlternates mAlternates = mRecognitionResult.GetAlternatesFromSelection();
//Create the array to copy alternates into
RecognitionAlternate[] theCopies = new RecognitionAlternate[mAlternates.Count];
//Copy the alternates to the array
mAlternates.CopyTo(theCopies, 0);

Platforms

Windows 7, Windows Vista, Windows Server 2008 R2, Windows Server 2008

The .NET Framework and .NET Compact Framework do not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.

Version Information

.NET Framework

Supported in: 3.0

See Also

Reference

RecognitionAlternates Class

RecognitionAlternates Members

Microsoft.Ink Namespace