User User - 4 years ago 86
C# Question

Change Integer value to Roundoff by the nearest integer

int a = 4;
int b = 3;
int c = a/b;


Here the c value as 1.33 . now i need to change the value as whole number like 2.

If,

int a =1;
int b = 2;
int c = a/b means the value is 0.5


now i need to change the value as next whole number like 1

Answer Source

Please try this:

int a =  4;
int b = 3;
int c = Convert.ToInt32(Math.Ceiling(a/b));
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download