我不断收到这个错误,我不确定我做错了什么.错误1'Home.Services.InventoryImpl'未实现接口成员'Home.Services.InventorySvc.CreateInventory(Home.Services.InventoryImpl)'
我的接口代码
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Home;
using Home.Domain;
namespace Home.Services
{
public interface InventorySvc
{
void CreateInventory(InventoryImpl CreateTheInventory);
}
}
Run Code Online (Sandbox Code Playgroud)
我的实施准则
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Home.Domain;
using System.IO;
using System.Runtime.Serialization;
using System.Runtime.Serialization.Formatters.Binary;
namespace Home.Services
{
public class InventoryImpl: InventorySvc
{
public void CreateTheInventory(CreateInventory createinventory)
{
FileStream fileStream = new FileStream
("CreateInventory.bin", FileMode.Create,
FileAccess.Write);
IFormatter formatter = new BinaryFormatter();
formatter.Serialize(fileStream, createinventory);
fileStream.Close();
}
}
}
Run Code Online (Sandbox Code Playgroud)
调用您的方法,CreateTheInventory但在接口中调用它CreateInventory.方法签名必须与接口成员完全匹配,以便编译器将该方法视为实现接口成员,并且名称不匹配.
此外,参数类型不匹配-在你执行你CreateInventory的参数类型,但接口需要类型的参数InventoryImpl.
如果你纠正了这两个错误,你的代码应该构建.
| 归档时间: |
|
| 查看次数: |
1130 次 |
| 最近记录: |