.net中验证码问题

来源:百度知道 编辑:UC知道 时间:2024/09/21 13:19:02
private void CreateCheckCodeImage(string checkCode)
{
//若校验码为空,则直接返回
if(checkCode==null||checkCode.Trim()==string.Empty)
{
return;
}

//根据校验码的长度确定输出图片的长度
System.Drawing.Bitmap image=new System.Drawing.Bitmap(
(int)Math.Ceiling((checkCode.Length*15)),20);

提示 此处private void CreateCheckCodeImage(string checkCode)
{
//若校验码为空,则直接返回
if(checkCode==null||checkCode.Trim()==string.Empty)
{
return;
}

//根据校验码的长度确定输出图片的长度
System.Drawing.Bitmap image=new System.Drawing.Bitmap(
(int)Math.Ceiling((checkCode.Length*15)),20);

提示此处 编译器错误信息: CS0121: 在以下方法或属性之间的调用不明确:“System.Math.Ceiling(decimal)”和“System.Math.Ceiling(double)”

请问该如何解决
我现在没什么积分 要不肯定是给100 谢谢

System.Math.Ceiling(...)有2个重载方法,参数分别为decimal和double。
你的“(int)Math.Ceiling((checkCode.Length*15))”中,checkCode.Length的类型是int变量,所以Math.Ceiling无法识别。
解决“(int)Math.Ceiling((checkCode.Length*15)d)”
或者“(int)Math.Ceiling((checkCode.Length*15)f)”

另外你可以自己去了解下System.Drawing.Size.Ceiling方法