Hashtable with different values for single key
c#, hashtable, ios-simulator, mono, monodevelop
Solution
A hashtable is defined as having unique keys, and the indexer replaces existing values. It sounds like you actually want a list of objects, i.e.
var list = new List<YourType> {
new YourType { Id = "x001.xhtml", MediaType = "...", Href = "..." },
new YourType { Id = "x002.xhtml", MediaType = "...", Href = "..." },
new YourType { Id = "x003.xhtml", MediaType = "...", Href = "..." }
};
with
public class YourType {
public string Id {get;set;}
public string MediaType {get;set;}
public string Href {get;set;}
}
(or similar)
Problem
if i have multiple values for same key then how to add it in hash table for example: ``` Hashtable hs = new Hashtable(); hs["id"]= "x001.xhtml"; hs["media-type"]= "application/xhtm+xml"; hs["href"]= "text/001.xhtml"; hs["id"]= "x002.xhtml"; hs["media-type"]= "application/xhtm+xml"; hs["href"]= "text/002.xhtml"; hs["id"]= "x003.xhtml"; hs["media-type"]= "application/xhtm+xml"; hs["href"]= "text/003.xhtml"; ``` this is taking only last group in hashtable i.e ``` hs["id"]= "x003.xhtml"; hs["media-type"]= "application/xhtm+xml"; hs["href"]= "text/003.xhtml"; ``` how to solve this....thanks in advance!!