I'm inserting a special (summary) row into a DataTable
, and I want it to appear last in a sorted DataView
. I know the DataView
is being sorted (ascending) by a particular string column, and for display purposes it doesn't matter what value appears in that column of the summary row.
What string can I place in that field to make sure my summary row gets sorted to the very end? For columns of nearly any other datatype, I could use T.MaxValue
, but there unfortunately is no System.String.MaxValue
constant.
I already tried
footerRow[colGrouping] = "\uFFFF";
but that sorted to the top! (DataView
sorting is lexicographical, not based on numeric value of the codepoint)
If I were to wing it without understanding lexicographical ordering I would say \uFF70
var table = new DataTable("table");
table.Columns.Add("column");
for (int i = 0; i < 65536; i++)
{
var row = table.NewRow();
row["column"] = (char)i;
table.Rows.Add(row);
}
var view = new DataView(table);
view.Sort = "column";
var last = ((string)view[65535]["column"])[0];
//last is 0xff70 'ー'
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With