Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我正在尝试创建 FileStream.Open 方法的接口。我已经开始但有点困惑:
public interface IFileDataSource { FileStream Open(string path, FileMode mode, FileAccess access, FileShare share); }
我需要包装这是另一个类才能使用这个接口吗?
您不需要“包装”它 - 但您确实需要实现它才能使用它。大概你会写一个简单的实现,它只是委托给File.Open:
File.Open
public class BclFileDataSource : IFileDataSource { public FileStream Open(string path, FileMode mode, FileAccess access, FileShare share) { return File.Open(path, mode, access, share); } }