Hello!
I know this must have an stupidly easy solution, but now I just can't find it :(
I have this collection:
IDictionary<String, List<String>> publishers = new Dictionary<String, List<String>>();
The keys will be some web publishers names, such as "wired.com",
"internet.com", etc. The values associated with these keys will be
lists of urls (I'll be reading the urls from a txt file). The code:
StreamReader sr = File.OpenText("blah.txt");
//initialize the dictionary structure
for (int j = 1; j <= numberOfPublishers; j++)
{
this.publishers.Add(publisherName, new List<String>());
}
string url = sr.ReadLine();
do
{
if (Regex.IsMatch(url, regular

Adding a item to a IDictionary<String, List<String>> object
Mystagogue
you can get access to publishers list by get item of publisher list with publisherName key ,then you have item.value (here url list) so sou can add url to this list here.
you can use fallowing solution:
publishers[publisherName].Add(url);
in place of:
publishers.Add(publisherName,X)Gidjett
Sorry, I didn't notice
Let's try again:
Hello!
I know this must have an stupidly easy solution, but now I just can't find it :(
I have this collection:
IDictionary<String, List<String>> publishers = new Dictionary<String, List<String>>();
The keys will be some web publishers names, such as "wired.com", "internet.com", etc. The values associated with these keys will be lists of urls (I'll be reading the urls from a txt file). The code:
StreamReader sr = File.OpenText("blah.txt");
//initialize the dictionary structure
for (int j = 1; j <= numberOfPublishers; j++)
{
this.publishers.Add(publisherName, new List<String>());
}
string url = sr.ReadLine();
do
{
if (Regex.IsMatch(url, regEx))
{
//The code to get the publisherName goes here
publishers.Add(publisherName,X)
}
url = sr.ReadLine();
} while (url != null);
How do I insert the url into the appropriate list What is the second argument for publishers.Add(....) I haven't found any metod that returns the value (list) associated to the key (publisherName) so I can insert the url string into it. I'm sure there is one, but I just can't find it :(
Thanks,
Anpiro
gabriele46
Alfitsi