1. Used always sealed classes when the class haven't any derived classes.
Some additional infos from this point:
The sealed modifier is primarily used to prevent unintended derivation,
but it also enables certain run-time optimizations. In particular, because a sealed class is
known to never have any derived classes, it is possible to transform virtual function member
invocations on sealed class instances into non-virtual invocations.
sealed类可以提高性能
2. Do not loop in a foreach loop over DataRows use the Select() method of the DataTable.
this code costs tooooo much:
foreach(DataRow currentDataRow in currentDataTable.Rows)
{
newDataTable.ImportRow(currentDataRow);
}
this code runs over 300 % faster (depends on rows count):
DataRow[] allRows = currentDataTable.Select();
foreach (DataRow currentDataRow in allRows)
{
newDataTable.ImportRow(currentDataRow);
}