Get TOP N from DataTable

        private DataTable GetTopN(DataTable dt, int RowCount, int Start)
        {
            DataTable table = dt.Clone();
            for(var i = Start; i <= Start + RowCount; i++)
            {
                if( i >= dt.Rows.Count ) break;
                table.ImportRow(dt.Rows[i]);
            }
 
            return table;
        }
programming/csharp/gettopnfromdatatable.txt · Last modified: 2018-06-21 19:48 (external edit)
CC Attribution-Noncommercial-Share Alike 4.0 International
Driven by DokuWiki Recent changes RSS feed Valid CSS Valid XHTML 1.0