CollectionBase BUG ??? [英] CollectionBase BUG???

查看:71
本文介绍了CollectionBase BUG ???的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述




有没有人对此有所了解:

..net文档说CollectionBase.RemoveAt(int index)是

虚方法,但是当我尝试覆盖它时,我得到编译器错误:

不能覆盖继承的成员

''System.Collections.CollectionBase.RemoveAt(int )''因为它不是

标记为虚拟,抽象或覆盖


这是某种bug还是什么?

如果这种方法不是真的虚拟那么这个类的重点是什么?b $ b是抽象的?我可以覆盖删除方法,但不能删除。

解决方案

SharpCoderMP,


文档可能有误。你应该重写的是

OnRemove或OnRemoveComplete方法提供自定义动作来执行

删除。


希望这有帮助。

-

- Nicholas Paldino [.NET / C#MVP]

- mv*@spam.guard.caspershouse.com


" SharpCoderMP" < CS ******* @ interia.pl.NFSPM>在消息中写道

news:或************** @ TK2MSFTNGP09.phx.gbl ...

hi,

有没有人知道这件事:
.net文档说CollectionBase.RemoveAt(int index)是虚方法,但是当我试图覆盖它时我得到编译器错误:
无法覆盖继承的成员
''System.Collections.CollectionBase.RemoveAt(int)''因为它没有标记为虚拟,抽象或覆盖

这是一些那种bug还是什么?
如果这种方法不是真的那么虚拟那么这个类的重点是什么呢?我可以覆盖删除方法,但不能删除。



感谢您的信息。

i将我的代码放在OnRemove中,它完成了诀窍,虽然错了

文件声明让我陷入了一些挫折:(

,这更糟糕,这不是第一次......


Nicholas Paldino [.NET / C#MVP]写道:

SharpCoderMP,

文档可能是错误的。你应该重写的是
OnRemove或OnRemoveComplete方法提供自定义操作以执行删除。

希望这会有所帮助。



SharpCoderMP,

我的一般规则是当文档失败时,使用Reflector(或者在大多数

的情况下首先使用Reflector)。 br $> b $ b -

- Nicholas Paldino [.NET / C#MVP]

- mv*@spam.guard.caspershouse.co m


" SharpCoderMP" < CS ******* @ interia.pl.NFSPM>在消息中写道

新闻:uy ************** @ TK2MSFTNGP11.phx.gbl ...

感谢您的信息。
我将我的代码放在OnRemove中并且它完成了诀窍,虽然错误的文档声明让我陷入了一些挫折:(
而且更糟糕的是这不是第一次。 ..

Nicholas Paldino [.NET / C#MVP]写道:

SharpCoderMP,

文档可能有误。你应该覆盖什么是OnRemove或OnRemoveComplete方法提供自定义操作以执行删除。

希望这会有所帮助。




hi,

does anyone know something about this:
..net documentation says that CollectionBase.RemoveAt(int index) is
virtual method, but when i try to override it i get compiler error:
cannot override inherited member
''System.Collections.CollectionBase.RemoveAt(int)'' because it is not
marked virtual, abstract, or override

is this some kind of bug or what?
if this method is not really virtual so what''s the point of this class
being abstract? i can override Remove method but cant RemoveAt.

解决方案

SharpCoderMP,

The documentation could be wrong. What you should be overriding is the
OnRemove or the OnRemoveComplete method to provide custom actions to perform
on removal.

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

"SharpCoderMP" <cs*******@interia.pl.NFSPM> wrote in message
news:Or**************@TK2MSFTNGP09.phx.gbl...

hi,

does anyone know something about this:
.net documentation says that CollectionBase.RemoveAt(int index) is virtual
method, but when i try to override it i get compiler error:
cannot override inherited member
''System.Collections.CollectionBase.RemoveAt(int)'' because it is not marked
virtual, abstract, or override

is this some kind of bug or what?
if this method is not really virtual so what''s the point of this class
being abstract? i can override Remove method but cant RemoveAt.



thanks for the info.
i put my code inside OnRemove and it did the trick, although wrong
documentation statement run me into some frustration :(
and what''s worse this wasn''t the first time...

Nicholas Paldino [.NET/C# MVP] wrote:

SharpCoderMP,

The documentation could be wrong. What you should be overriding is the
OnRemove or the OnRemoveComplete method to provide custom actions to perform
on removal.

Hope this helps.



SharpCoderMP,

My general rule is when documentation fails, use Reflector (or in most
cases use Reflector first).
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com

"SharpCoderMP" <cs*******@interia.pl.NFSPM> wrote in message
news:uy**************@TK2MSFTNGP11.phx.gbl...

thanks for the info.
i put my code inside OnRemove and it did the trick, although wrong
documentation statement run me into some frustration :(
and what''s worse this wasn''t the first time...

Nicholas Paldino [.NET/C# MVP] wrote:

SharpCoderMP,

The documentation could be wrong. What you should be overriding is
the OnRemove or the OnRemoveComplete method to provide custom actions to
perform on removal.

Hope this helps.




这篇关于CollectionBase BUG ???的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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