Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
How can one class set a property to be seen by another c
Message
General information
Forum:
ASP.NET
Category:
Coding, syntax and commands
Environment versions
Environment:
C# 4.0
OS:
Windows 7
Network:
Windows 2003 Server
Database:
MS SQL Server
Miscellaneous
Thread ID:
01566989
Message ID:
01567011
Views:
28
>>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; }
>        }
>    }
Am I right in assuming that this would only work if InvokeString is defined in the top of the hyarchy class right? Is there a way to do is for properties that are defined in intermediary level classes?

If things have the tendency to go your way, do not worry. It won't last. Jules Renard.
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform