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

Popular posts from this blog

java - SSE Emitter : Manage timeouts and complete() -

jquery - uncaught exception: DataTables Editor - remote hosting of code not allowed -

java - How to resolve error - package com.squareup.okhttp3 doesn't exist? -