抽象类'没有实现接口成员......' [英] abstract class 'does not implement interface member ...'

查看:77
本文介绍了抽象类'没有实现接口成员......'的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我得到了

C:\Programming\LTM\devtools\UselessJunkForDissasse mbly\Class1.cs(360,27):

错误CS0535: ''UselessJunkForDissassembly.InvocableInternals''没有

实现接口成员

''UselessJunkForDissassembly.IInvocableInternals.Op erationValidate(string)''

C :\Programming\LTM\devtools\UselessJunkForDissasse mbly\Class1.cs(360,27):

错误CS0535:''UselessJunkForDissassembly.InvocableInternals''没有

实现接口成员

''UselessJunkForDissassembly.IInvocableInternals.Pr oxiedOperation''


编译时:

公共接口IInvocable

{

对象操作{get; } b / b
内部接口IInvocableInternals:IInvocable

{

bool OperationValidate(string args);

string ProxiedOperation {get; } $ / $
}

公共抽象类InvocableInternals:IInvocableInternals

{

公共对象Operation {get {return ProxiedOperation; } $

}


但是,我已经知道课程没有实现这些功能。这就是为什么

它是* abstract *。请注意,我已经用

对象或字符串替换了所有复杂类型,以进行最小化的再现。我不希望公开暴露我的内部

函数,我无法隐藏InvocableInternals因为公共

类继承它,我不想使用货运代理因为,我是

确信JIT无法内联它。

为什么不允许只执行

" IInvocableInternals.OperationValidate"在派生程度最高的类中?

I get
C:\Programming\LTM\devtools\UselessJunkForDissasse mbly\Class1.cs(360,27):
error CS0535: ''UselessJunkForDissassembly.InvocableInternals'' does not
implement interface member
''UselessJunkForDissassembly.IInvocableInternals.Op erationValidate(string)''
C:\Programming\LTM\devtools\UselessJunkForDissasse mbly\Class1.cs(360,27):
error CS0535: ''UselessJunkForDissassembly.InvocableInternals'' does not
implement interface member
''UselessJunkForDissassembly.IInvocableInternals.Pr oxiedOperation''

when compiling:
public interface IInvocable
{
object Operation { get; }
}
internal interface IInvocableInternals : IInvocable
{
bool OperationValidate(string args);
string ProxiedOperation { get; }
}
public abstract class InvocableInternals : IInvocableInternals
{
public object Operation { get { return ProxiedOperation; } }
}

But, I already knew the class didn''t implement those functions. That''s why
it is *abstract*. Please note that I''ve replaced all complicated types with
object or string to make a minimal reproduction. I don''t want my internal
functions exposed publicly, I can''t hide InvocableInternals because public
classes inherit from it, and I don''t want to use a forwarder because, I''m
convinced that the JIT wouldn''t be able to inline it.
Why isn''t it allowed to just implement
"IInvocableInternals.OperationValidate" in the most derived class?

推荐答案

Ben,


根据语言规范:


20.4.5抽象类和接口


1.像非抽象类一样,抽象类必须提供实现

。类的基类列表中列出的接口的所有成员的b。


或者你问为什么语言规范是这样的?

-

- Nicholas Paldino [.NET / C#MVP]

- mv*@spam.guard.caspershouse.com


Ben Voigt [C ++ MVP]" < rb*@nospam.nospamwrote in message

news:%2 **************** @ TK2MSFTNGP06.phx.gbl ...
Ben,

According to the language specification:

20.4.5 Abstract classes and interfaces

1. Like a non-abstract class, an abstract class must provide implementations
of all members of the interfaces that are listed in the base class list of
the class.

Or are you asking why the language specification is this way?
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com

"Ben Voigt [C++ MVP]" <rb*@nospam.nospamwrote in message
news:%2****************@TK2MSFTNGP06.phx.gbl...

>我得到

C:\Programming\LTM\devtools\UselessJunkForDissasse mbly\Class1.cs(360,27) :

错误CS0535:''UselessJunkForDissassembly.InvocableInternals''没有

实现接口成员

''UselessJunkForDissassembly.IInvocableInternals.Op erationValidate(string )''

C:\Programming\LTM\devtools\UselessJunkForDissasse mbly\Class1.cs(360,27):

错误CS0535:'' UselessJunkForDissassembly.InvocableInternals''没有

实现接口成员

''UselessJunkForDissassembly.IInvocableInternals.Pr oxiedOperation''


编译时:

公共接口IInvocable

{

对象操作{get; } b / b
内部接口IInvocableInternals:IInvocable

{

bool OperationValidate(string args);

string ProxiedOperation {get; } $ / $
}

公共抽象类InvocableInternals:IInvocableInternals

{

公共对象Operation {get {return ProxiedOperation; } $

}


但是,我已经知道课程没有实现这些功能。那是'/ b $ b为什么它是*抽象*。请注意,我已经用对象或字符串替换了所有复杂的

类型,以进行最小的再现。我不希望

我的内部函数公开暴露,我无法隐藏InvocableInternals

,因为公共类继承了它,我不想使用

货运代理,因为,我确信JIT无法内联

它。

为什么不是'它只允许实施

" IInvocableInternals.OperationValidate"在派生程度最高的类中?
>I get
C:\Programming\LTM\devtools\UselessJunkForDissasse mbly\Class1.cs(360,27):
error CS0535: ''UselessJunkForDissassembly.InvocableInternals'' does not
implement interface member
''UselessJunkForDissassembly.IInvocableInternals.Op erationValidate(string)''
C:\Programming\LTM\devtools\UselessJunkForDissasse mbly\Class1.cs(360,27):
error CS0535: ''UselessJunkForDissassembly.InvocableInternals'' does not
implement interface member
''UselessJunkForDissassembly.IInvocableInternals.Pr oxiedOperation''

when compiling:
public interface IInvocable
{
object Operation { get; }
}
internal interface IInvocableInternals : IInvocable
{
bool OperationValidate(string args);
string ProxiedOperation { get; }
}
public abstract class InvocableInternals : IInvocableInternals
{
public object Operation { get { return ProxiedOperation; } }
}

But, I already knew the class didn''t implement those functions. That''s
why it is *abstract*. Please note that I''ve replaced all complicated
types with object or string to make a minimal reproduction. I don''t want
my internal functions exposed publicly, I can''t hide InvocableInternals
because public classes inherit from it, and I don''t want to use a
forwarder because, I''m convinced that the JIT wouldn''t be able to inline
it.
Why isn''t it allowed to just implement
"IInvocableInternals.OperationValidate" in the most derived class?





" Nicholas Paldino [。NET / C#MVP]" < mv*@spam.guard.caspershouse.com写在

消息新闻:uW **************** @ TK2MSFTNGP03.phx.gbl ...

"Nicholas Paldino [.NET/C# MVP]" <mv*@spam.guard.caspershouse.comwrote in
message news:uW****************@TK2MSFTNGP03.phx.gbl...

Ben,


根据语言规范:


20.4。 5抽象类和接口


1.与非抽象类一样,抽象类必须提供所列接口的所有成员的实现
实现

类的基类列表。
Ben,

According to the language specification:

20.4.5 Abstract classes and interfaces

1. Like a non-abstract class, an abstract class must provide
implementations of all members of the interfaces that are listed in the
base class list of the class.



好​​的,但由于界面是内部的,我应该被允许:


公共接口IInvocable

{

对象操作{get; }

}


内部接口IInvocableInternals:IInvocable

{

bool OperationValidate(string args) ;


string ProxiedOperation {get; } $ / $
}

公共抽象类InvocableInternals:IInvocableInternals

{

内部抽象字符串ProxiedOperation {得到; } $ / $
公共对象操作{get {return ProxiedOperation; }}

}

Ok, but since the interface is internal, I should be allowed to:

public interface IInvocable
{
object Operation { get; }
}

internal interface IInvocableInternals : IInvocable
{
bool OperationValidate(string args);

string ProxiedOperation { get; }
}

public abstract class InvocableInternals : IInvocableInternals
{
internal abstract string ProxiedOperation { get; }
public object Operation { get { return ProxiedOperation; } }
}


>

或者你问为什么语言规范是这样的?< br $> b
$ b -

- Nicholas Paldino [.NET / C#MVP]

- mv*@spam.guard.caspershouse.com


" Ben Voigt [C ++ MVP]" < rb*@nospam.nospamwrote in message

news:%2 **************** @ TK2MSFTNGP06.phx.gbl ...
>
Or are you asking why the language specification is this way?
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com

"Ben Voigt [C++ MVP]" <rb*@nospam.nospamwrote in message
news:%2****************@TK2MSFTNGP06.phx.gbl...

>>我得到了
C:\Programming\LTM\devtools\UselessJunkForDissass embly\Class1.cs(360,27):<错误CS0535:''UselessJunkForDissassembly.InvocableInternals''没有实现接口成员
''UselessJunkForDissassembly.IInvocableInternals.O perationValidate(string)''
C:\Programming \ LTM\devtools\UselessJunkForDissass embly\Class1.cs(360,27):
错误CS0535:''UselessJunkForDissassembly.InvocableInternals''没有实现接口成员
''UselessJunkForDissassembly。 IInvocableInternals.P roxiedOperation''

编译时:
公共接口IInvocable
对象操作{get; }
}内部接口IInvocableInternals:IInvocable
{bool OperationValidate(string args);
string ProxiedOperation {get;公共抽象类InvocableInternals:IInvocableInternals
公共对象操作{get {return ProxiedOperation;但是,我已经知道班级没有实现这些功能。这就是为什么它是*抽象*。请注意,我已经用对象或字符串替换了所有复杂的
类型,以进行最小化的再现。我不想要公开公开我的内部功能,我不能隐藏InvocableInternals
因为公共类继承了它,我不想使用
转发器,因为,我确信JIT无法内联它。
为什么不允许它只是实现
IInvocableInternals.OperationValidate。在最派生的课程中?
>>I get
C:\Programming\LTM\devtools\UselessJunkForDissass embly\Class1.cs(360,27):
error CS0535: ''UselessJunkForDissassembly.InvocableInternals'' does not
implement interface member
''UselessJunkForDissassembly.IInvocableInternals.O perationValidate(string)''
C:\Programming\LTM\devtools\UselessJunkForDissass embly\Class1.cs(360,27):
error CS0535: ''UselessJunkForDissassembly.InvocableInternals'' does not
implement interface member
''UselessJunkForDissassembly.IInvocableInternals.P roxiedOperation''

when compiling:
public interface IInvocable
{
object Operation { get; }
}
internal interface IInvocableInternals : IInvocable
{
bool OperationValidate(string args);
string ProxiedOperation { get; }
}
public abstract class InvocableInternals : IInvocableInternals
{
public object Operation { get { return ProxiedOperation; } }
}

But, I already knew the class didn''t implement those functions. That''s
why it is *abstract*. Please note that I''ve replaced all complicated
types with object or string to make a minimal reproduction. I don''t want
my internal functions exposed publicly, I can''t hide InvocableInternals
because public classes inherit from it, and I don''t want to use a
forwarder because, I''m convinced that the JIT wouldn''t be able to inline
it.
Why isn''t it allowed to just implement
"IInvocableInternals.OperationValidate" in the most derived class?




Ben,


我现在看到你得到了什么。这是一件让我感到沮丧的事情。老实说,我从来没有看到任何陷阱让

允许这样做,因为抽象方法与虚拟方法相同

无论如何从派生类上看。
< br $> b $ b -

- Nicholas Paldino [.NET / C#MVP]

- mv*@spam.guard.caspershouse.com


" Ben Voigt [C ++ MVP]" < rb*@nospam.nospamwrote in message

news:Oc ************** @ TK2MSFTNGP06.phx.gbl ...
Ben,

I see what you are getting at now. This is one of the things that has
always frustrated me as well. Honestly, I never saw any pitfalls to
allowing this, since abstract methods are the same as virtual methods
anyways when seen from the derived class on.

--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com

"Ben Voigt [C++ MVP]" <rb*@nospam.nospamwrote in message
news:Oc**************@TK2MSFTNGP06.phx.gbl...

>

" Nicholas Paldino [.NET / C#MVP]" < mv*@spam.guard.caspershouse.com写了
消息新闻中的
:uW **************** @ TK2MSFTNGP03.phx.gbl ...
>
"Nicholas Paldino [.NET/C# MVP]" <mv*@spam.guard.caspershouse.comwrote
in message news:uW****************@TK2MSFTNGP03.phx.gbl...

> Ben,

根据语言规范:

20.4.5抽象类和接口

1。与非抽象类一样,抽象类必须提供类的
基类列表中列出的所有接口成员的实现。
>Ben,

According to the language specification:

20.4.5 Abstract classes and interfaces

1. Like a non-abstract class, an abstract class must provide
implementations of all members of the interfaces that are listed in the
base class list of the class.



好​​的,但由于界面是内部的,我应该被允许:


公共接口IInvocable

{

对象操作{get; }

}


内部接口IInvocableInternals:IInvocable

{

bool OperationValidate(string args) ;


string ProxiedOperation {get; } $ / $
}

公共抽象类InvocableInternals:IInvocableInternals

{

内部抽象字符串ProxiedOperation {得到; } $ / $
公共对象操作{get {return ProxiedOperation; }}

}


Ok, but since the interface is internal, I should be allowed to:

public interface IInvocable
{
object Operation { get; }
}

internal interface IInvocableInternals : IInvocable
{
bool OperationValidate(string args);

string ProxiedOperation { get; }
}

public abstract class InvocableInternals : IInvocableInternals
{
internal abstract string ProxiedOperation { get; }
public object Operation { get { return ProxiedOperation; } }
}


>>
或者你在问这个语言规范的原因是什么?

-
- Nicholas Paldino [.NET / C#MVP]
- mv * @ spam。 guard.caspershouse.com

Ben Voigt [C ++ MVP]" < rb*@nospam.nospamwrote in message
新闻:%2 **************** @ TK2MSFTNGP06.phx.gbl ...
>>
Or are you asking why the language specification is this way?
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com

"Ben Voigt [C++ MVP]" <rb*@nospam.nospamwrote in message
news:%2****************@TK2MSFTNGP06.phx.gbl...

>>>我得到了
C:\Programming\LTM \ devtools \ UselessJunkForDissas sembly\Class1.cs(360,27):
错误CS0535:''UselessJunkForDissassembly.InvocableInternals''没有实现接口成员
''UselessJunkForDissassembly.IInvocableInternals。 OperationValidate(string)''
C:\Programming\LTM\devtools\UselessJunkForDissas sembly\Class1.cs(360,27):
错误CS0535:''UselessJunkForDissassembly.InvocableInternals''没有实现接口成员
''UselessJunkForDissassembly.IInvocableInternals。 ProxiedOperation''

编译时:
公共接口IInvocable
{对象操作{get; }
}内部接口IInvocableInternals:IInvocable
{bool OperationValidate(string args);
string ProxiedOperation {get;公共抽象类InvocableInternals:IInvocableInternals
公共对象操作{get {return ProxiedOperation;但是,我已经知道班级没有实现这些功能。这就是为什么它是*抽象*。请注意,我已经用对象或字符串替换了所有复杂的
类型,以进行最小化的再现。我不希望我的内部功能公开暴露,我无法隐藏
InvocableInternals因为公共类继承了它,我不想使用转发器,因为,我确信JIT不会内联它。
为什么不允许它只是实现
IInvocableInternals.OperationValidate在派生程度最高的班级?
>>>I get
C:\Programming\LTM\devtools\UselessJunkForDissas sembly\Class1.cs(360,27):
error CS0535: ''UselessJunkForDissassembly.InvocableInternals'' does not
implement interface member
''UselessJunkForDissassembly.IInvocableInternals. OperationValidate(string)''
C:\Programming\LTM\devtools\UselessJunkForDissas sembly\Class1.cs(360,27):
error CS0535: ''UselessJunkForDissassembly.InvocableInternals'' does not
implement interface member
''UselessJunkForDissassembly.IInvocableInternals. ProxiedOperation''

when compiling:
public interface IInvocable
{
object Operation { get; }
}
internal interface IInvocableInternals : IInvocable
{
bool OperationValidate(string args);
string ProxiedOperation { get; }
}
public abstract class InvocableInternals : IInvocableInternals
{
public object Operation { get { return ProxiedOperation; } }
}

But, I already knew the class didn''t implement those functions. That''s
why it is *abstract*. Please note that I''ve replaced all complicated
types with object or string to make a minimal reproduction. I don''t
want my internal functions exposed publicly, I can''t hide
InvocableInternals because public classes inherit from it, and I don''t
want to use a forwarder because, I''m convinced that the JIT wouldn''t be
able to inline it.
Why isn''t it allowed to just implement
"IInvocableInternals.OperationValidate" in the most derived class?





这篇关于抽象类'没有实现接口成员......'的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆