Submitted anonymously: "I found this in a data access layer for an application testing framework. The object has fields that are obviously meant to contain integers, doubles, and DateTime objects, but they are all strings and this is the only constructor:
class LineItem { // SNIP: 28 public string fields public LineItem(Object[] fields) { int index = 0; //limit initial memory assigned for line items due to infrequent use lineItems = new List(0); foreach (Object field in fields) { switch (index++) { case 0: category = field.ToString(); break; case 1: paymentMethod = field.ToString(); break; case 2: transDate = field.ToString(); break; case 3: amountCurrency = field.ToString(); break; case 4: exchangeCode = field.ToString(); break; case 5: exchangeRate = field.ToString(); break; case 6: documentNumber = field.ToString(); break; case 7: location = field.ToString(); break; case 8: dateFrom = field.ToString(); break; case 9: dateTo = field.ToString(); break; case 10: deduction_breakfast = field.ToString(); break; case 11: deduktion_lunch = field.ToString(); break; case 12: deduktion_dinner = field.ToString(); break; case 13: mealDeduktion = field.ToString(); break; case 14: accountNumber = field.ToString(); break; case 15: projectId = field.ToString(); break; case 16: description = field.ToString(); break; case 17: salesTaxGroup = field.ToString(); break; case 18: itemSalesTaxGroup = field.ToString(); break; case 19: additionalInformation = field.ToString(); break; case 20: miles = field.ToString(); break; case 21: rate_per_mile = field.ToString(); break; case 22: advanceRequestedDate = field.ToString(); break; case 23: department = field.ToString(); break; case 24: cost_center = field.ToString(); break; case 25: purpose = field.ToString(); break; case 26: timeFrom = field.ToString(); break; case 27: timeTo = field.ToString(); break; } } } }
"The worst part is that this isn't even generated code. It was written by hand, and there are 16 other classes just like it, resulting in a 2100 line .cs file. The original developer must have missed the day that strong-typed datasets were explained in his C# class."