How in need across the class references data dictionary, data intact, how to create the corresponding dictionary can in across class instantiation, bother, let us know,
CodePudding user response:
The static,
CodePudding user response:
Memorycache.
CodePudding user response:
reference 1st floor is nu month god reply: static, This took, was in the same class, but because of the format problem, I am like that, I use the a, b, c three classes, a good class to encapsulate the corresponding dictionary, class b write method, data problems is that after entering the class b dictionary data is normal, but in class c is going to call a dictionary data, data loss, should be I build problems, cause when I went to class c tuning, data appear problem, I go to invoke the static across class I also tried to have problems, may be I use problem, please some directions superiors, or what is the effective way to solve it, CodePudding user response:
Static completely meet your needs, it is recommended that you stick the existing code CodePudding user response:
Say of good strange, dictionary is a reference type, you know CodePudding user response:
1. Find all references to see there is a clear, removeall, new 2. Put the things into static readonly -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- this will prevent you new, but the clear proof, so is there any place to see 1 clear 3. When multiple use, suggest use thread safety in the dictionary CodePudding user response:
The reference 4 floor hands on the keyboard to knock very light response: static completely meet your needs, it is recommended that you stick existing code out refer to 6th floor wanghui0380 response: 1. Find all references to see there is a clear, removeall, new 2. Put the things into static readonly -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- this will prevent you new, but the clear proof, so is there any place to see 1 clear 3. Suggest use thread safety when multiple places use dictionary Uh huh, the problem to find out, thank you