PropertyInfo:属性是索引器吗?

时间:2021-05-23 21:03:32

I have the following code :

我有以下代码:

PropertyInfo[] originalProperties = myType.GetProperties();

I want to exclude from originalProperties all the indexers (myVar["key"] appears as property named "Item").

我想从originalProperties中排除所有索引器(myVar [“key”]显示为名为“Item”的属性)。

What is the proper way ?

什么是正确的方法?

Exclude all properties where propInfo.Name == "Item" is not an option.

排除propInfo.Name ==“Item”不是选项的所有属性。

1 个解决方案

#1


64  

Call PropertyInfo.GetIndexParameters - if the returned array is empty, it's not an indexer.

调用PropertyInfo.GetIndexParameters - 如果返回的数组为空,则它不是索引器。

#1


64  

Call PropertyInfo.GetIndexParameters - if the returned array is empty, it's not an indexer.

调用PropertyInfo.GetIndexParameters - 如果返回的数组为空,则它不是索引器。