public int CompareTo(FrequencyBL au2, FrequencyBLComparer.ComparisonType comparisonType) { FrequencyBLComparer.ComparisonType baseComparisonType = comparisonType; Int32 compareResult = 0; Int32 descFlag = 1; //-1 for descending, + 1 for ascending, multiply by compare result switch (comparisonType) { case FrequencyBLComparer.ComparisonType.iDays: descFlag = 1; compareResult = iDays.CompareTo(au2.iDays); break; case FrequencyBLComparer.ComparisonType.strFrequency: descFlag = 1; compareResult = strFrequency.CompareTo(au2.strFrequency); break; default: descFlag = 1; compareResult = iDays.CompareTo(au2.iDays); break; } return(compareResult * descFlag); //desc flag of -1 returns negative result for descending sort }
private static List <FrequencyBL> BuildFromTable(DataTable dtTable) { List <FrequencyBL> list = new List <FrequencyBL>(); if (dtTable != null) { foreach (DataRow dr in dtTable.Rows) { FrequencyBL thisMember = new FrequencyBL(dr); list.Add(thisMember); } } return(list); }