>>>
>>Look at Bonnie's article in April 2007 of Universal Thread Magazine:
>>>>>
>>>>>http://www.levelextreme.com/ViewPageArticle.aspx?Session=352B65654B536B4830706B3D204F455A6670646F5559727967654E5A6F6B55635076513D3D
>>>>
>>>>Looks like Bonnie omitted a parameter:if (PemStatus(oObject, "SetFocusAtAdd") && _
:-{ >>>
>>>Oops, yep, looks like it. My bad.
>>>
>>>The underscore in that line, which is a continuation character in VB but not valid in C#, was added to what I originally submitted (this was C# code) ... the magazine editor must have done that.
>>>
>>>~~Bonnie
>>
>>
>>You can also use linQ to see if the property exists and to return the properties value.
>>
>>if( MyClass.GetType().GetProperty (propName) != null)
>>{
>> object propValue = MyClass.GetType().GetProperty(propName).GetValue(MyClass, new object[]{});
>>}
>>
>
>Where does Linq come into that?
>Oh - and before Gregory beats me to it - assigning a value to GetProperty() in the if clause would avoid having to re-evaluate if it's not null.....
Its testing for the existence of the property before getting the value thereof.
Just one reference:
http://aabs.wordpress.com/2006/11/13/linq-reflection-in-c-30/ I just finished Charlie Calvert's book "Essential LinQ" and he covers this in detail. I just didn't choose to use from...where... select... syntax. There are many ways to skin the same horst.