Browse Source

Merge pull request #8452 from workgroupengineering/fixes/Warnings/DataGrid

fix(DataGrid): CS8073 The result of the expression is always 'true'
Max Katz 3 years ago
parent
commit
377248d491
1 changed files with 8 additions and 9 deletions
  1. 8 9
      src/Avalonia.Controls.DataGrid/DataGrid.cs

+ 8 - 9
src/Avalonia.Controls.DataGrid/DataGrid.cs

@@ -5990,15 +5990,14 @@ namespace Avalonia.Controls
         /// <returns>The formatted string.</returns>
         private string FormatClipboardContent(DataGridRowClipboardEventArgs e)
         {
-            StringBuilder text = new StringBuilder();
-            for (int cellIndex = 0; cellIndex < e.ClipboardRowContent.Count; cellIndex++)
-            {
-                DataGridClipboardCellContent cellContent = e.ClipboardRowContent[cellIndex];
-                if (cellContent != null)
-                {
-                    text.Append(cellContent.Content);
-                }
-                if (cellIndex < e.ClipboardRowContent.Count - 1)
+            var text = new StringBuilder();
+            var clipboardRowContent = e.ClipboardRowContent;
+            var numberOfItem = clipboardRowContent.Count;
+            for (int cellIndex = 0; cellIndex < numberOfItem; cellIndex++)
+            {
+                var cellContent = clipboardRowContent[cellIndex];
+                text.Append(cellContent.Content);
+                if (cellIndex < numberOfItem - 1)
                 {
                     text.Append('\t');
                 }