要求是这样的:为了统一接口,我要继承一个DLL中的接口,然后新建一个类,使用相同的命名空间,实现接口里的功能。DLL的代码是这样的:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Drawing;namespace LinkImgAutoCrop
{
public interface ILinkImgAutoCrop
{
Bitmap AutoCrop(Bitmap inputImg, out bool isSuccess, out string errMsg,params object[] paras);
}
}我引用了这个DLL:using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Drawing;using BOCBANCSLinkImgAutoCrop;namespace ImgAutoCrop
{
public class ImgAutoCrop : BOCBANCSLinkImgAutoCrop.IBOCBANCSLinkImgAutoCrop
{
public Bitmap AutoCrop(Bitmap inputImg, bool isSuccess, string errMsg, params object[] paras)
{
KXImageCvt m_imageCvt = null;//KXImageCvt是一个实现的类
m_imageCvt = new KXImageCvt(1600, 1200, 3); return m_imageCvt.AutoCorp(inputImg, isSuccess, errMsg);//AutoCrop成员函数实现了要求的功能。
}
}
}这样就提示我:ImgAutoCrop.ImgAutoCrop does not implement interface member 'BOCBANCSLinkImgAutoCrop.IBOCBANCSLinkImgAutoCrop.AutoCrop(System.Drawing.Bitmap, out bool, out string, params object[]请问,我要怎么写这个格式,才能实现我最上面所说的要求呢
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Drawing;namespace LinkImgAutoCrop
{
public interface ILinkImgAutoCrop
{
Bitmap AutoCrop(Bitmap inputImg, out bool isSuccess, out string errMsg,params object[] paras);
}
}我引用了这个DLL:using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Drawing;using BOCBANCSLinkImgAutoCrop;namespace ImgAutoCrop
{
public class ImgAutoCrop : BOCBANCSLinkImgAutoCrop.IBOCBANCSLinkImgAutoCrop
{
public Bitmap AutoCrop(Bitmap inputImg, bool isSuccess, string errMsg, params object[] paras)
{
KXImageCvt m_imageCvt = null;//KXImageCvt是一个实现的类
m_imageCvt = new KXImageCvt(1600, 1200, 3); return m_imageCvt.AutoCorp(inputImg, isSuccess, errMsg);//AutoCrop成员函数实现了要求的功能。
}
}
}这样就提示我:ImgAutoCrop.ImgAutoCrop does not implement interface member 'BOCBANCSLinkImgAutoCrop.IBOCBANCSLinkImgAutoCrop.AutoCrop(System.Drawing.Bitmap, out bool, out string, params object[]请问,我要怎么写这个格式,才能实现我最上面所说的要求呢
{
Bitmap AutoCrop(Bitmap inputImg, out bool isSuccess, out string errMsg,params object[] paras);
}
public class ImgAutoCrop : BOCBANCSLinkImgAutoCrop.IBOCBANCSLinkImgAutoCrop
{
public Bitmap AutoCrop(Bitmap inputImg, bool isSuccess, string errMsg, params object[] paras)
{
两个AutoCrop的参数不一样
改成
public Bitmap AutoCrop(Bitmap inputImg, bool isSuccess, out string errMsg, params object[] paras)
public class ImgAutoCrop : BOCBANCSLinkImgAutoCrop.IBOCBANCSLinkImgAutoCrop
{}
把光标指向BOCBANCSLinkImgAutoCrop.IBOCBANCSLinkImgAutoCrop
在第一个字母B下面有一个蓝色的下划线。点下划线,选择“实现接口”。VS会自动实现所有需要实现的方法的代码框架。剩下的你只要做填空题就可以了。