Message 1 of 4
Testing if a class has a certain Property
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Hi All!
I've put together a c# routine which lists parameters of elements the user selects.
Some of the parameters have a value which is an ElementId, rather than returning the ElementId (which means little to the user), I'd like the routine to return the name of the object the Id refers to.
To get the objects Human Readable Name I'm obtaining the element and then calling the Name Property:
pickparam is the a Parameter variable. Element getob = doc.GetElement(pickparam.AsElementId()); String getresult = getob.Name;
This works fine - some of the time, as some of the Element the parameter refers to don't have a Name Property.
To stop the code failing, I'd like to test for this with an If statement, i.e.
if (getobName != null) { String getresult = getob.Name } else { String getresult = "something else" }
The above code doesn't work, how can I test for a Classes Property such as Name?
(I hope the above is understandable!)
Thanks.