我有一个实现接口的类:
I've got a class that implements an interface:
public class SQLiteHHSDBUtils : IHHSDBUtils { void IHHSDBUtils.SetupDB() { . . . if (!TableExists("AppSettings")) . . . bool IHHSDBUtils.TableExists(string tableName) { . . .它找不到自己的兄弟坐在它下面(如果(!TableExists()):
It can't find its own brother sitting right below it (the if (!TableExists()):
当前上下文中不存在名称TableExists
The name 'TableExists' does not exist in the current context
它怎么能/为什么看不到它?
How can it / why does it not see it?
推荐答案你有一个显式的接口实现。你不能直接访问你的接口方法,除非你把当前实例转换为接口类型:
You have an explicit interface implementation. You can't access your interface methods directly unless you cast current instance to interface type:
if (!((IHHSDBUtils)this).TableExists("AppSettings"))来自 13.4.1明确的界面成员实施
在方法调用,属性访问或索引器访问中,无法通过其完全限定名访问显式接口成员实现。成员实施只能通过接口实例访问,并且在这种情况下只能通过其成员名称引用。
It is not possible to access an explicit interface member implementation through its fully qualified name in a method invocation, property access, or indexer access. An explicit interface member implementation can only be accessed through an interface instance, and is in that case referenced simply by its member name.
更多推荐
为什么这个实现方法看不到它的兄弟?
发布评论