Creating a list of double string items

Situation:
You can to create a List object to save two different string values, without using string splits or substrings.

Solution:
Use the KeyValuePair structure.

 public List<KeyValuePair<string, string>> GetAllTimeZones()
        {
            List <KeyValuePair<string, string>> timeZones = new List<KeyValuePair<string, string>>();
            timeZones.Add(new KeyValuePair<string, string>(string1, string2));
            }
            return timeZones;
        }


To retrieve data:
foreach (KeyValuePair<string, string> currentTimeZone in GetAllTimeZones())
                {
                    ddlTimeZones.Items.Add(new ListItem(currentTimeZone.Key, currentTimeZone.Value));
                }

Comments

Popular posts from this blog

Breaking down document locking in SharePoint

Working around X-Frame-Options for iframes

Document ID not being generated