|
dev
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
Set Value for Property in base class.I have a problem when im trying to set a value for a property in the base class. the following example shows what i currently have... Example: Base Class public class Person { public string Name { get {return m_Name;} set {m_Name=value;} } } Child Class public class student: Person { public string Place { get {return m_Place;} set {m_Place=value;} } } -------------- Now i have a function where i pass the name of the property, the value and an instance of the class... example: LoopProperties(sStudent,"Place","test") and the function loops in the properties of the class and set the value... im using .GetProperties to get the list and im looping using foreach and setting the value using property.SetValue() However there is a chance that the function receive the property Name (which is in the base class of student) example: LoopProperties(sStudent,"Name","testname") how can i set the property Name when i only have an instance of the class student?? Thanks Ruben >how can i set the property Name when i only have an instance of the class GetProperties returns inherited properties as well so I'd expect your>student?? existing code to work in this case too. Mattias -- Mattias Sjögren [C# MVP] mattias @ mvps.org http://www.msjogren.net/dotnet/ | http://www.dotnetinterop.com Please reply only to the newsgroup. |
|||||||||||||||||||||||