Skip to content

Commit

Permalink
Refactor DataGridViewColumnCollection to replace ArrayList (#8153)
Browse files Browse the repository at this point in the history
Co-authored-by: Igor Velikorossov <RussKie@users.noreply.github.com>
  • Loading branch information
elachlan and RussKie authored Nov 10, 2022
1 parent a979ed8 commit 25a3497
Show file tree
Hide file tree
Showing 3 changed files with 54 additions and 98 deletions.
Original file line number Diff line number Diff line change
@@ -1,34 +1,24 @@
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.

#nullable disable

using System.Collections;
using System.Diagnostics;

namespace System.Windows.Forms
{
public partial class DataGridViewColumnCollection
{
private class ColumnOrderComparer : IComparer
private class ColumnOrderComparer : IComparer<DataGridViewColumn>
{
public ColumnOrderComparer()
{
}

public int Compare(object x, object y)
public int Compare(DataGridViewColumn? x, DataGridViewColumn? y)
{
Debug.Assert(x is not null);
Debug.Assert(y is not null);

DataGridViewColumn dataGridViewColumn1 = x as DataGridViewColumn;
DataGridViewColumn dataGridViewColumn2 = y as DataGridViewColumn;

Debug.Assert(dataGridViewColumn1 is not null);
Debug.Assert(dataGridViewColumn2 is not null);

return dataGridViewColumn1.DisplayIndex - dataGridViewColumn2.DisplayIndex;
return x.DisplayIndex - y.DisplayIndex;
}
}
}
Expand Down
Loading

0 comments on commit 25a3497

Please sign in to comment.