【发布时间】:2014-01-12 21:31:39
【问题描述】:
我运行我的 C# 应用程序,它很大,所以我只包含了一部分代码
我的代码:
allowGift = Convert.ToInt32(dRow[14]) == 1;
allowInventoryStack = Convert.ToInt32(dRow[15]) == 1;
interactionType = InterractionTypes.GetTypeFromString((string)dRow[16]); //Line of error
以及堆栈跟踪的错误
System.InvalidCastException:无法将类型为“System.Boolean”的对象转换为类型“System.String”
【问题讨论】:
-
dRow的类型是什么?interactionType的类型是什么?是哪一行导致了错误? -
您似乎在使用this class。虽然下面的大多数答案都是善意的,但它们不会起作用,因为
InteractionType没有从True或False转换。很抱歉,根据您提供给我们的信息,您的问题无法回答。 -
查看
InteractionType枚举(包括“football”、“teleport”和“firegate”等值),并确保您传递给GetTypeFromString的值是在那里。