We help IT Professionals succeed at work.

We've partnered with Certified Experts, Carl Webster and Richard Faulkner, to bring you two Citrix podcasts. Learn about 2020 trends and get answers to your biggest Citrix questions!Listen Now


Error Message ambiguous method or properties

MoniMatthews asked
Medium Priority
Last Modified: 2013-11-26
I am getting this error message:
The call is ambiguous between the following methods or properties: 'System.Math.Min(byte, byte)' and 'System.Math.Min(int, int)'

Below is my code:
I get the error on the precision =

private List<SqlParameter> createParametersFromColumns(string tableName, SqlConnection conn)
		string sqlSelect = "select * from " + tableName;
		SqlCommand cmd = new SqlCommand(sqlSelect, conn);
		SqlDataReader r = cmd.ExecuteReader(CommandBehavior.KeyInfo);
		DataTable dt = r.GetSchemaTable();
		SqlParameter param;
		string name;
		SqlDbType type;
		int size;
		bool nullable;
		byte precision;
		byte scale;
		List<SqlParameter> @params = new List<SqlParameter>(dt.Rows.Count);
		foreach (DataRow row in dt.Rows) 
            name = row["ColumnName"].ToString();
			if (!_schemaAuthority.Contains(name)) continue; 
			type = (SqlDbType)Enum.Parse(typeof(SqlDbType), row["DataTypeName"].ToString(), true);
			size = Convert.ToInt32(row["ColumnSize"]);
			nullable = Convert.ToBoolean(row["AllowDBNull"]);
            precision = Math.Min(Convert.ToByte(row["NumericPrecision"].ToString()), 4);
			//call max out at precision=4 to account for all records that erroneously report precision as '255'
			scale = Convert.ToByte(row["NumericScale"]);
			param = new SqlParameter(name, type, size, ParameterDirection.Input, true, precision, scale, name, DataRowVersion.Original, null
		return @params;

Open in new window

Watch Question

.Net Developer
modify to this in your code :

precision = Math.Min(Convert.ToByte(row["NumericPrecision"].ToString()),(byte) 4);

Not the solution you were looking for? Getting a personalized solution is easy.

Ask the Experts
Kevin CrossChief Technology Officer
Most Valuable Expert 2011

shakashico is correct as the system compiler doesn't know for sure if 4 is meant to be a byte or an int in this case.  Casting to byte will make this clear.
Access more of Experts Exchange with a free account
Thanks for using Experts Exchange.

Create a free account to continue.

Limited access with a free account allows you to:

  • View three pieces of content (articles, solutions, posts, and videos)
  • Ask the experts questions (counted toward content limit)
  • Customize your dashboard and profile

*This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.


Please enter a first name

Please enter a last name

8+ characters (letters, numbers, and a symbol)

By clicking, you agree to the Terms of Use and Privacy Policy.