Не удается неявно преобразовать тип float в int - C#

Узнай цену своей работы

Формулировка задачи:

private void Awake()
    {
        if (PlayerPrefs.HasKey("SV"))
        {
            float totalBonusPS = 0 ;
            sv = JsonUtility.FromJson<Save>(PlayerPrefs.GetString("SV"));
            score = sv.score;
            for (int i = 0; i < shopItems.Count; i++)
            {
                
                shopItems[i].levelOfItem = sv.levelOfItem[i];
                shopItems[i].bonusCounter = sv.bonusCounter[i];
                if (shopItems[i].needCostMultiplier) shopItems[i].cost *= (int)Mathf.Pow(shopItems[i].costMultiplier, shopItems[i].levelOfItem);
                if (shopItems[i].bonusIncrease != 0) scoreIncrease += (int)Mathf.Pow(shopItems[i].bonusIncrease, shopItems[i].levelOfItem);
 
                    totalBonusPS += shopItems [i].bonusPerSec * shopItems [i].bonusCounter;
            }
            DateTime dt = new DateTime (sv.date[0],sv.date[1],sv.date[2],sv.date[3],sv.date[4],sv.date[5]); 
            TimeSpan ts = DateTime.Now - dt;
            float offlineBonus = (float)ts.TotalSeconds * totalBonusPS; 
            score += offlineBonus ; 
            print("Вы отсутствовали: " + ts.Days + "Д. " + ts.Hours + "Ч. " + ts.Minutes + "М. " + ts.Seconds + "S.");
            print ("Вы заработали " + offlineBonus + "$");
        }
    }
нужно поменять с int в float когда меняю пишет (не удается неявно преобразовать тип float в int )

Решение задачи: «Не удается неявно преобразовать тип float в int»

textual
Листинг программы
float a = 0.0;
int b = Convert.ToInt32(a);

Оцени полезность:

9   голосов , оценка 3.889 из 5
Похожие ответы