![]() 'This code produces the following output. Void PrintIndexAndValues( IEnumerable^ myList )Ĭonsole::WriteLine( "\t[", i, obj) ![]() IComparer^ m圜omparer = gcnew myReverserClass Ĭonsole::WriteLine( "After sorting with the reverse case-insensitive comparer:" ) Sorts the values of the ArrayList using the reverse case-insensitive comparer. Sorts the values of the ArrayList using the default comparer.Ĭonsole::WriteLine( "After sorting with the default comparer:" ) Return ((gcnew CaseInsensitiveComparer)->Compare( y, x )) Virtual int Compare( Object^ x, Object^ y ) sealed = IComparer::Compare Calls CaseInsensitiveComparer.Compare with the parameters reversed. Ref class myReverserClass: public IComparer Void PrintIndexAndValues( IEnumerable^ myList ) The following code example shows how to sort the values in an ArrayList using the default comparer and a custom comparer that reverses the sort order. CopyTo(Array, Int32) Copies the entire ArrayList to a compatible one-dimensional Array, starting at the specified index of the target array. This method is an O(n) operation, where n is Count. Null is passed for comparer, and the elements in the list do not implement IComparable. The elements are copied to the Array in the same order in which the enumerator iterates through the ArrayList.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |