因此,我有一个项目正在进行中。这是我唯一的错误:将Float转换为Int
不能将类型'float'隐式转换为'int'。
我的理解在某种程度上意味着什么。我只需要帮助将我的float转换为int。
这只是花车的一个示例:
float key = 0.5f;
int key = 53;
下面是具体的代码段:
// price in scrap, e.g. 29/9 = 3.33 ref
static int BuyPricePerTOD = 21;
// price in scrap, e.g. 31/9 = 3.55 ref
static float SellPricePerTOD = BuyPricePerTOD + 0.5F;
static int BuyPricePerKey = 53;
static float SellPricePerKey = BuyPricePerKey + 0.5F;
static int TimerInterval = 170000;
static int InviteTimerInterval = 2000;
int UserWeapAdded,UserScrapAdded,UserRecAdded,UserRefAdded,
UserKeysAdded,UserTODAdded,BotTODsAdded,BotKeysAdded,
BotScrapAdded,BotRecAdded,BotRefAdded,InventoryMetal,
InventoryScrap,InventoryRec,InventoryRef,InventoryKeys,
InventoryTOD,PreviousTODs,PreviousKeys,WhileLoop,InvalidItem = 0;
float UserMetalAdded, BotMetalAdded, OverpayNumKeys,
OverpayNumTOD, ExcessInScrapKey, ExcessInScrapTOD = 0.0F;
double ExcessRefinedKey, ExcessRefinedTOD = 0.0;
你可以展示一些你迄今为止所做的代码吗? – Edper
@ user3325320 .. int _value = Convert.ToInt32(key); –
你想转一圈吗?或者你只是想截断?例如'1.8'四舍五入为'2',但截断为'1'。 –