Skip to content

Instantly share code, notes, and snippets.

@codewithcats
Created April 17, 2012 21:02
Show Gist options
  • Save codewithcats/2409032 to your computer and use it in GitHub Desktop.
Save codewithcats/2409032 to your computer and use it in GitHub Desktop.
Calculate Unit Per Day
public int calUnit()
{
decimal result = Convert.ToDecimal((Power / 1000.00) * Duration);
string[] str;
int font;
if (result.ToString().Contains('.'))
{
str = result.ToString().Split('.');
font = Convert.ToInt32(str[0]);
if (Convert.ToInt32(str[1]) > 0)
{
font += 1;
}
}
else
{
font = Convert.ToInt32(result);
}
return font;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment