c# - 属性信息 : is the property an indexer?

标签 c# .net reflection propertyinfo

我有以下代码:

PropertyInfo[] originalProperties = myType.GetProperties();

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

什么是正确的方法?

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

最佳答案

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

关于c# - 属性信息 : is the property an indexer?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4746188/

相关文章:

c# - 如何通过反射调用基类的方法?

c# - 如何从java程序调用c#dll

c# - 按一定顺序组合列表c#

c# - 调用具有类名称的网站上的按钮?

c# - 图像源绑定(bind)到丢失的文件

.net - 使用Windows窗体设计器添加用户控件

.net - Powershell Get-SCVirtualDiskDrive 生成​​公共(public)语言规范 (CLR) 错误

java - 通用对象创建方法的返回类型

ruby-on-rails - 返回自身的 Ruby 方法

c# - 在任务中捕获异常的最佳方法是什么?