Making a cast:
using static System.Console;
public class Program {
public static void Main() {
int valorUni = 8;
int valorTotal = 116;
double result = ((double)valorUni / valorTotal) * 100;
WriteLine(result);
}
}
Behold working in the ideone. And in the .NET Fiddle. Also put on the Github for future reference.
If you order to split two integers the result can only be integer, then you need to transform at least one of them into double
so that the result has decimal places.
But note that it seems that you are working with monetary value. double
should not be used for monetary value. See What is the correct way to use the float, double and decimal types?.
Anyway it is not to give the result that is waiting.