因此,我有一個項目正在進行中。這是我唯一的錯誤:將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'。 –