The following code throws an InvalidCastException.
public static MachineProductCollection MachineProductsForMachine(
MachineProductCollection MachineProductList, int MachineID)
{
return (MachineProductCollection)
MachineProductList.FindAll(c => c.MachineID == MachineID);
}
This surprises me since MachineProductCollection is merely a generic List of MachineProducts which is exactly FindAll() returns. Here’s the full MachineProductCollection source code:
[Serializable]
public [...]
Continue reading about InvalidCastException Though Same Base Class
We ran into the following issue two days ago. In a nutshell, the “initialCategory” was not being selected in the Categories dropdown by default. Yes, I recognize that the code itself may be written in fewer lines, but please only focus on the differences between the two code snippets below. I haven’t had the time to [...]
If you like to drive your fellow developers mad, here’s something fun. The next time you need to manage a bunch of dates, add them to a Hashtable AFTER converting ToString(). For example,
DateTime holiday = new DateTime(2007,1,1); Hashtable htHolidays = new Hashtable(); htHolidays.Add(holiday.ToString(), holiday.ToString()); …
Next, create a function similar to the following:
public static bool isHoliday(string [...]
I picked up a new development box the other day and I spent most of yesterday (heck, it was ALL of yesterday) getting the machine configured. Nearly all software installed without any issues except for SQL Server 2005 Developer Edition. After completing the installation, I planned to validate the installation by first checking to see [...]