Click here to Skip to main content
15,920,633 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi,

Im trying to loop through and edit a list of properties, whislt also skipping property types of guid.

C#
<pre lang="text">

foreach (var property in Props)
                    {                        
                        if (property.CanWrite && property.GetType() != typeof(Guid))
                        {
                            //DoStuff
                        }
                    }


This doesnt skip over the guid, hope can i skip guid types?

Thanks
Posted

Your variable named property is of type PropertyInfo (maybe don't overuse var keyword?)

just ask for the property type

so
C#
if (property.CanWrite && property.PropertyType != typeof(Guid))
 
Share this answer
 
Try if (property.CanWrite && property.GetType().ToString() != "System.Guid").
 
Share this answer
 
Comments
johannesnestler 18-Jun-14 10:27am    
no you didn't spot his mistake, property is a PropertyInfo... and replacing with a string comparison is not "so good" too...

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