INTERNET APPLICATION DEVELOPMENT
MID MARKET ERP DEVELOPMENT
By Derek Du
You may want to use hasOwnProperty () and isPropertyEnumerable to further filter the properties, but it is simple enough.
Also to add or delete a property is just as simple as:
The best part is that you can retrieve a property just using a string variable to match its name.
Of course, a well-developed language such as C# must also have a way to dynamically work on properties – Reflection.
Reflection can achieve many things but here we are only going to talk about property manipulation.
To get a list of properties of an object:
To traverse an object’s properties and work with them:
It is worth mentioning that when retrieving a certain property with its name, ignoring case may be needed. To achieve that:
Note that all three binding flags are necessary, otherwise it won’t work.
To learn more about this, go to:
This is a repost of Derek’s blog, Stuff.