How can I write the if statement to check if the keys are not in the dictionary
when I have a dictionary in a dictionary?
I started the if statement, but I do not know how to finish it.
Code is below.
Thanks,
arep
public static Dictionary<string, Dictionary<string, DebOop>> d = new Dictionary<string, Dictionary<string, DebOop>>();
public static void GetData(string memberNbr, string person, string group, string subGroup, string plancode, string date)
{
int year = (DateTime.ParseExact(date, "yyyy-MM-dd", CultureInfo.InvariantCulture)).Year;
//Is key not in dictionary
if (!d.ContainsKey(memberNbr))
{
UpdateData(memberNbr, person, group, subGroup, plancode, date);
}
}
Loading
A RepaskyPosted Aug 21, 2011, 12:30 AM
I will put the final result when I get the production program done. I will not get back to it until monday. I figure I should put the finally result when done. Also, I will probably have another question.
arep
VulpesPosted Aug 19, 2011, 6:33 PM
A RepaskyPosted Aug 19, 2011, 5:27 PM
Now two things. I still have to get this all working in the production class. And I do not understand why he had these two if statements. Everything is the same except for the year. I do not know if you could shed any light on this?
VulpesPosted Aug 19, 2011, 4:21 PM
I've also added the highlighted code to your record class:
A RepaskyPosted Aug 19, 2011, 4:00 PM
A RepaskyPosted Aug 19, 2011, 2:56 PM
getting is "<1>" for all the Console.Writeline's. I am using the KeyValuePair in a foreach.
Thanks,
Arep
VulpesPosted Aug 18, 2011, 4:35 PM
public static void GetData(string memberNbr, string person, string group, string subGroup, string plancode, string date)
{
int year = (DateTime.ParseExact(date, "yyyy-MM-dd", CultureInfo.InvariantCulture)).Year;
//Is key not in dictionary
if (!d.ContainsKey(memberNbr)) // memberNbr isn't in outer dictionary
{
UpdateData(memberNbr, person, group, subGroup, plancode, date);
}
else // memberNbr is in outer dictionary
{
Dictionary
if(!dict.ContainsKey(year.ToString()) // but year isn't in inner dictionary for memberNbr outer key
{
UpdateData(memberNbr, person, group, subGroup, plancode, date);
}
}
}
A RepaskyPosted Aug 18, 2011, 4:24 PM
VulpesPosted Aug 18, 2011, 4:18 PM
A RepaskyPosted Aug 18, 2011, 4:09 PM
My add is not working either. Here it is:
Here is my add statement:d.Add((memberNbr,); I do not know how this should be written. I have tried "(" also.
VulpesPosted Aug 18, 2011, 3:59 PM