Вопрос

I know this is basic one I'm asking, bear with me.

I'm trying to find out the percentage.

This is what I'm trying, but it is giving me an error of ambiguous call.

int total = 1;
int totalUsers = 3;
if (totalUsers > 0)
{
    var per =Math.Round(total / totalUsers,4) * 100 ;
    object[] args = new object[] { total, totalUsers, per };
    lblMsg.Text = string.Format("{0} of {1} users already voted({2}%)", args);
}

 

For Example:
if total = 1
totalusers = 3 
per should be after rounding of 33.33%
Это было полезно?

Решение

To resolve the ambiguous call error, change to:

var per =Math.Round((decimal)total / totalUsers,4) * 100 ;
Лицензировано под: CC-BY-SA с атрибуция
Не связан с StackOverflow
scroll top