Click here to Skip to main content
15,887,746 members
Please Sign up or sign in to vote.
3.00/5 (1 vote)
See more:
i have a code
C#
PropertyInfo[] Properties = myType.GetProperties();

i exclude indexer from above properties array by using below code
C#
ParameterInfo[] parms=propertyInfo.GetIndexParameters();

if(parms.length==0)
{


}

I want to know if there is any problem occur due to exclude indexer from property info collection by using above way.please let me know about that.
Posted
v2
Comments
Not clear. What you are trying to achieve?
Sergey Alexandrovich Kryukov 8-Aug-15 2:42am    
I think it's quite clear. The inquirer just omitted some code, but it's apparent that she/he wants to traverse all public properties of some type, except indexed properties.

The idea is quite correct; I only cannot understand why the inquirer could not just read original MSDN documentation.

Please see Solution 1.

—SA

1 solution

Yes, you can do it exactly this way: https://msdn.microsoft.com/en-us/library/system.reflection.propertyinfo.getindexparameters%28v=vs.110%29.aspx[^].

This documentation tells you that it always returns the array, but its length can be zero, which happens if the property is not indexed.

—SA
 
Share this answer
 
Comments
Sergey Alexandrovich Kryukov 8-Aug-15 5:49am    
Thank you, Tadit.
—SA
Member 11849380 8-Aug-15 6:10am    
Hi Sergey,
I want to know due to exclude indexes from property collection if there is any problem will occur for indexes behavior. for example i want to implement IDataErrorInfo in my Application.Because of excluding the IDataErroRInfo will run or not
Sergey Alexandrovich Kryukov 8-Aug-15 6:21am    
I already answered. What is unclear? Problems appear if you create them.
If you want more detail, provide more detail. But first, please accept my answer formally.
—SA

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900