Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Why do we need to re-build the dictionary?
Message
 
 
To
02/06/2017 01:29:38
General information
Forum:
C#
Category:
Coding, syntax and commands
Miscellaneous
Thread ID:
01651719
Message ID:
01651741
Views:
41
Thanks, Gregory. I implemented something like that, but I think I need to make the dictionary private. I also added a public static boolean property telling me when to re-build it (after each save of the preferences).

>There may be a reason why it's rebuilt every time. You'll need to look into that.
>
>
>static private  Dictionary<string, object> PreferencesDictionary =   BuildPreferencesDictionary();
>
>
>
> static public Dictionary<string, object> GetPreferenceDictionary()
>        {
>            return PreferencesDictionary;
>        }
>
>
>
>
>
>
>>Hi everybody,
>>
>>I see the following code being called:
>>
>>
>> static public Dictionary<string, object> GetPreferenceDictionary()
>>        {
>>            return BuildPreferencesDictionary();
>>        }
>>
>>
>>
>>and then in the same class
>>
>>
>> static private Dictionary<string, object> BuildPreferencesDictionary()
>>        {
>>            Dictionary<string, object> preferenceDictionary = new Dictionary<string, object>();
>>           //loading code here
>>
>>            return preferenceDictionary;
>>        }
>>
>>
>>
>>this method is called many times.
>>
>>Why cannot we just return the dictionary if it was already created? What do I need to change here to make this simpler and to build only once?
>>
>>Thanks in advance.
If it's not broken, fix it until it is.


My Blog
Previous
Reply
Map
View

Click here to load this message in the networking platform