fxWind5bal
New Member
Assume I have a collection of objects\[code\]List<MyClass> collection = new List<MyClass>();\[/code\]And a dictionary where these objects will be inserted\[code\]Dictionary<string, List<MyClass>> sections = new Dictionary<string, List<MyClass>>();// example of insertionsections["A"].Add(collection[2]);\[/code\]List and dictionary are stored in a \[code\]ViewState\[/code\]. Will it be more memory-friendly to store identifiers of objects in the dictionary and bind them with objects later, when I need them?\[code\]Dictionary<string, List<int>> sections = new Dictionary<string, List<int>>();// example of insertionsections["A"].Add(collection[2].ID);\[/code\]As I understand there will be no performance boost because in the first case dictionary will contain references which are 32/64 bits in size. Is it true?EDIT\[code\]MyClass\[/code\] is a class, not a struct.List and Dictionary are declared like this:\[code\]private List<MyClass> A{ get { if (ViewState["a"] == null) { ViewState["a"] = // retrieve data from db } return (List<MyClass>)ViewState["a"]; } set { ViewState["a"] = value; }}private Dictionary<string, List<MyClass>> B{ get { if (ViewState["b"] == null) { ViewState["b"] = new Dictionary<string, List<MyClass>>(); } return (Dictionary<string, List<MyClass>>)ViewState["b"]; } set { ViewState["b"] = value; }}\[/code\]