c# - cannot implicitly convert type 'float' to 'int' -
when try run following code gives error " cannot implicitly convert type 'float' 'int' ".
i have done lot of searches, , sadly wasn't able find such error.
int sum1, cols, rows; float h, twoends, x; sum1 = (h - ((cols) * x) + twoends)) / (cols + 1);
the errors puts clear
cannot implicitly convert type 'float' 'int'
so have float
result can't converted implictly sum1
of type int
. try converting/casting explicitly:
sum1 = (int) ((h - ((cols) * x) + twoends)) / (cols + 1));
Comments
Post a Comment