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:
01567024
Views:
27
>>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; }
>        }
>    }
This doesn't seem to work for me. I implemented it this same way and added the methods SetInvokeString and new String InvokeString in both classes. However, after I set the property in one class, the same property in another class is still null.

Here is what I have in the base class:
protected virtual String InvokeString { get; set; }
I have two separate classes that inherit from this one. In both I added the exact same code as you showed.

One of them has
  public String Invoke(String input)
      {
         Dictionary<String, String> parameters = new Dictionary<String, String>(StringComparer.OrdinalIgnoreCase);

         this.SetInvokeString(input);
And in the other class I added also both methods and I have this code:
Logging.Log(String.Format("Calling Remote VoidPaymentPlanPass On {0} with: ", ip, this.InvokeString));
When I debug my test I see that this.InvokeString is null.

What did I do wrong?
If it's not broken, fix it until it is.


My Blog
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform