Static void main (string [] ARGs)
{
Decimal dvalue = 400.5 m;
Console. writeline (math. Round (dvalue, 0). tostring ());
Console. writeline (rounddecimal (dvalue). tostring ());
Dvalue = 40.5 m;
Console. writeline (math. Round (dvalue, 0). tostring ());
Console. writeline (rounddecimal (dvalue). tostring ());
Dvalue = 44.5 m;
Console. writeline (math. Round (dvalue, 0). tostring ());
Console. writeline (rounddecimal (dvalue). tostring ());
Dvalue = 4.5 m;
Console. writeline (math. Round (dvalue, 0). tostring ());
Console. writeline (rounddecimal (dvalue). tostring ());
Console. Read ();
}
Public static decimal rounddecimal (decimal dvalue)
{
Return dvalue. tostring (). split ('. '). length = 2 & convert. todecimal (dvalue. tostring (). split ('. ') [0]) % 4 = 0? (Convert. todecimal (dvalue. tostring (). Split ('.') [1]) = 5? Convert. todecimal (dvalue. tostring (). split ('. ') [0]) + 1: math. round (dvalue, 0): math. round (dvalue, 0 );
}
The output result is as follows: