Assign null to a SqlParameter
问题 The following code gives an error - \"No implicit conversion from DBnull to int.\" SqlParameter[] parameters = new SqlParameter[1]; SqlParameter planIndexParameter = new SqlParameter(\"@AgeIndex\", SqlDbType.Int); planIndexParameter.Value = (AgeItem.AgeIndex== null) ? DBNull.Value : AgeItem.AgeIndex; parameters[0] = planIndexParameter; 回答1: The problem is that the ?: operator cannot determine the return type because you are either returning an int value or a DBNull type value, which are not