<?xml version="1.0" encoding="utf-16" standalone="yes"?>
<BOY_B1UP_DOTNETCODE>
  <Code>RowCount</Code>
  <Name>Row count of matrix</Name>
  <U_BOY_DOTDYCO>//Duplicate check dynamic code (Boyum IT / tbm)Item i = form.Items.Item("38");     // Set form itemMatrix m = (Matrix)i.Specific;      // Access Matrixint rowCount = m.VisualRowCount;    // Get line countstring sValue = "";                 // Return string// Create a list of all item numbersstring[] itemCodes = new string[rowCount];// Put all itemcodes in an arrayint rowrun = 1;for (int runs = 0; runs &lt; rowCount; runs++){  itemCodes[runs] = ((SAPbouiCOM.EditText)m.Columns.Item("1").Cells.Item(rowrun).Specific).Value;  rowrun++;}//Create LINQ dictionary from all the duplicatesSystem.Collections.Generic.Dictionary&lt;string, int&gt; counts = itemCodes.GroupBy(x =&gt; x)                                      .ToDictionary(g =&gt; g.Key,                                                    g =&gt; g.Count());//Create return stringforeach (var kvp in counts){    //Check if Key is empty    if (kvp.Key != "") {        //Check if itemcode only appears once        if (kvp.Value &gt; 1) {        //Add the item code + row + occurances to the return string        sValue += string.Format("Duplicate item {0} found on row "+ (Array.IndexOf(itemCodes, kvp.Key)+ 1) +" - Duplicate amount: {1} &lt;NEWLINE&gt;", kvp.Key, kvp.Value);        }    }}//Return message based on sValue lengthif (sValue.Length == 0) {return "";}else {return sValue;}</U_BOY_DOTDYCO>
  <U_BOY_DOTDYCOL>0</U_BOY_DOTDYCOL>
  <U_BOY_DOTDYCOR>System.Core.dll;</U_BOY_DOTDYCOR>
  <U_BOY_DOTDYCOU>System.Linq;</U_BOY_DOTDYCOU>
</BOY_B1UP_DOTNETCODE>