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
From
27/02/2013 09:50:43
 
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:
01567040
Views:
24
>>>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?
>>
>>Works for me
>
>Can you please post your exact test case, so I can try comparing it with mine. Did you add these methods in both classes?
>
	public static class qqq
	{
		static void Main()
		{
			ClassB xx = new ClassB();
			xx.DoTest();

		}
}
	public class ClassA
	{
		public 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; }
        }

		public void DoTest()
		{
			SetInvokeString("pp");

			string xx = InvokeString;   
// breakpoint here

		}
	
		
	}
>E.g. I have middlewarebase class that has protected virtual property. I have middlewareMain class that has Invoke method and the two methods to set and return invokestring. I also have Sales class with the exact same methods of setting and getting that string.
>
>I set the invokestring in the MiddlewareMain and I need to read it in Sales class.

Of course - if you set an instance property of classX, don't expect that this will change an instance property of classY
Gregory
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform