djs120
asked on
Invalid Cast exception with hashtable
I have the following code. expCollection is a hashtable that contains a collection of classes of type TRI.FarmSelect.Expense:
private void getBudgetItemPrices(Hashta ble expCollection, int budgetID, int regionCode)
{
/* Loop through expenses collection and for each expense find prices/costs and assign */
foreach(TRI.FarmSelect.Exp ense expense in expCollection)
{
if (DB.getBudgetItemCost(Resp onse, budgetID, regionCode, expense))
{
/* do stuff... */
}
}
}
I get a runtime error "Specified cast is not valid" in the foreach statement. I am positive that the expCollection contains classes of the Expense type. Why would it give this runtime error? Thanks.
private void getBudgetItemPrices(Hashta
{
/* Loop through expenses collection and for each expense find prices/costs and assign */
foreach(TRI.FarmSelect.Exp
{
if (DB.getBudgetItemCost(Resp
{
/* do stuff... */
}
}
}
I get a runtime error "Specified cast is not valid" in the foreach statement. I am positive that the expCollection contains classes of the Expense type. Why would it give this runtime error? Thanks.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER