>>Hi everybody,
>>
>>In the base class I defined a public property with simple
>>
>>Public InvokeString {get;set;}
>>
>>I have two classes that inherit from that main class. In one of the classes I have a method where I can set this property. My problem is that I want another class to be able to read that new property value.
>>
>>Is there a way to solve it? Should I use static keyword here for the property only?
>
>Not sure I understand your requirement but I don't see how 'static' would help. Maybe something like this?:
public class ClassA
> {
> protected virtual string InvokeString { get; set; }
> }
>
> public class ClassB : ClassA
> {
> public void SetInvokeString(string s)
> {
> base.InvokeString = s;
> }
>
> public new string InvokeString
> {
> get { return base.InvokeString; }
> }
> }
I like this solution. I'll discuss with other developers if we should go for it or an extra separate class idea.
If it's not broken, fix it until it is.
My Blog