.NET: ERROR: The call is ambiguous between the following methods or properties: 'System.Math.Floor(decimal)' and 'System.Math.Floor(double)'
Here's a solution to solve this issue: The call is ambiguous between the following methods or properties: 'System.Math.Floor(decimal)' and 'System.Math.Floor(double)'

0 Comments   Posted by LazyAssCoder on Feb 25, 2009   1056 Views   Report Abuse
Tags: c#

Bookmark and Share

The following sample code produces this error message: The call is ambiguous between the following methods or properties: 'System.Math.Floor(decimal)' and 'System.Math.Floor(double)'


int width = 16;
int height = 9;
 
int positon = (int)(Math.Floor((height - width) / 2));



Solution

Using the floor function requires you to pass in either decimal or double data types.  If your passing in int, then all need need to do is to cast it to either decimal or double data type.

int width = 16;
int height = 9;
 
int positon = (int)(Math.Floor(((decimal)height - (decimal)width) / 2));


Comments

Login or Register to add a comment.