我跑我的C#应用程序,它是很大的,所以我只是包含的代码布尔在C#中的字符串?
我的代码的一部分:
allowGift = Convert.ToInt32(dRow[14]) == 1;
allowInventoryStack = Convert.ToInt32(dRow[15]) == 1;
interactionType = InterractionTypes.GetTypeFromString((string)dRow[16]); //Line of error
和堆栈跟踪的误差
System.InvalidCastException:无法铸造Typpe'System.Boolean'的对象以键入'System.String'
什么是'dRow'类型的其他地方做了
Converter
类? 'interactionType'的类型是什么?以及哪条线路导致错误? – Liel您似乎正在使用[此课程](https://github.com/Gnuns/Bfly/blob/master/Butterfly%20Emulator/HabboHotel/Items/InteractionType.cs)。尽管下面的大多数答案都是善意的,但它们将不起作用,因为“InteractionType”没有从“True”或“False”转换。根据您提供给我们的信息,我很抱歉地说您的问题无法回答。 –
查看'InteractionType'枚举(其中包括诸如“football”,“teleport”和“firegate”之类的值),并确保传递给'GetTypeFromString'的值在那里。 –