David Rozando
David Rozando

Reputation: 92

In vb. net, How to know whether an object has specific property

I want to do translation recursively on all components in my form. So my function will start on the form. Before the recursion, it's obvious that I have to know what property containing the children that the current Object has.

e.g.

The method I want to use it, I will check if the current object has property Items if not, check if it has property Tabs, and so on... Then the last fallback, check if it has property Controls.

Now the very question how could I check if the current object has specific Property? NB without prompting any error...

Upvotes: 2

Views: 2490

Answers (1)

You can use reflection to do this, but that means you take a performance hit.

Alternately you can do it with the Is operator to check to see what kind of Object you have and then casting to that type.

Upvotes: 1

Related Questions