David Chen

David Chen

  • NA
  • 50
  • 45.7k

Dictionary TryGetValue Help

Oct 9 2010 1:17 AM

I provided the source code, it basicly retrieves data from a file and read that file store it into a List then outputting it by using KeyValuePair
Below is where I am currently at, and final output, the difference is "Author Name: " and final output is "Author Name: Bruna Martinuzzi" (with respective order)

It will output like this but im dont know how to start by creating an Authors Dictionary. I need to enable cross referencing between authors.csv and books.csv data files and parse the data from each line of the authors.csv file and store it in an Author object. store each author object in a dictionary collection named authors. then when initialiizing the Book object look up the author's first and last names from this Dictionary

I created a list AddAuthors which retrieves data off from the data file then I split it and store each in a string array, authorDetail, then pass onto objects
I also created a
Dictionary<string, string> displayAuthor = new Dictionary<string, string>();
eventually I want to compare/catch the bookID and authorID then output it out
an example would be like this below, but the problem is a bit complicated since it has sealed or abstract class which confuse me.
can anyone help me out by using the Dictionary TryGetValue?

Dictionary<float, char> accounts = new Dictionary<float, char>();
float key1 = 10.20f;
char value1 = 'a';
accounts.Add(key1, value1);
char value;
if (accounts.TryGetValue(10.20f, out value))
{
    Console.WriteLine("Key {0} is associated with value {1}", 10.20f, value);
}
    Console.ReadLine();

Attachment: help.zip

Answers (1)