类型'A'已包含'Item'的定义 [英] The type 'A' already contains a definition for 'Item'
本文介绍了类型'A'已包含'Item'的定义的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
class A
{
public int Item()
{
throw new NotImplementedException();
}
public int this[int x] // error CS0102: The type 'A' already contains a definition for 'Item'
{
get { throw new NotImplementedException(); }
}
}
感谢您的帮助....
regrads
Nikhil
Thanks for your help....
regrads
Nikhil
推荐答案
是的,这是真的。
你们的成员都被称为Item
。
有一个名为Item
的方法和一个索引器......(所有索引器都被自动调用项目
)
例如,只需查看类列表
的文档。看看会员。你应该看到Item
。单击它,您将查看有关索引器的文档!
Yes, that's true.
Both your members are calledItem
.
There is a method calledItem
and an indexer... (all indexers are automatically calledItem
)
Just have a look at the documentation for classList
for example. There look at the members. You should seeItem
. Click on it and you will be viewing the documentation about the indexer!
this是一个关键字 - 您不能将任何方法,字段或属性命名为this。
更改名称,一切都会好的。
"this" is a keyword - you cannot name any method, field or property "this".
Change the name, and all will be well.
这篇关于类型'A'已包含'Item'的定义的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文