Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Conversion from C# to VB.NET
Message
From
18/04/2013 02:45:57
 
 
To
17/04/2013 17:47:15
General information
Forum:
ASP.NET
Category:
Coding, syntax and commands
Environment versions
Environment:
VB 9.0
OS:
Windows 7
Network:
Windows 2003 Server
Database:
MS SQL Server
Application:
Web
Miscellaneous
Thread ID:
01571173
Message ID:
01571298
Views:
42
>After more thinking about this, I think it is normal we are not allowed to assigned a NameObjectCollectionBase object to another one as its main root would differ at first making sense for the error message I am getting at the designer level. It might work for a dictionary but not for a NameObjectCollectionBase object.
>
>I will have to try with the locking mechanism instead.
>
>In the meantime, if you see a workaround with the 2nd approach or if you would know why I am getting this, feel free to let me know.

NameObjectCollectionBase or dictionary - the class is does not matter


I've used the volatile keyword http://msdn.microsoft.com/en-us/library/x13ttww7.aspx
See also here http://www.yoda.arachsys.com/csharp/threads/volatility.shtml
	public class AClass
	{
		private volatile Dictionary<string, string> Tables_;
	
		public Dictionary<string, string> Tables
		{
			get; private set; 

		}

		public AClass()
		{
			// Initialize Tables
			Tables_ = new Dictionary<string, string>();
			Tables_.Add("1", "one");
			Tables_.Add("2", "two");
		}
		public void ReInitializeTables()
		{
			// do not set to null

			Dictionary<string, string> tmp = new Dictionary<string, string>();
			tmp.Add("3", "three");
			tmp.Add("4", "four");

			Tables_ = tmp;  // assign new initialized object

		}
	}
Gregory
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform