List
The get data, and went in, but read and write, how to read ah, don't know the bosses told once, what is the case have a look at it, so make this the first time, CodePudding user response:
int i=1; If (dic) either ContainsKey (I)) { Foreach (var item dic in [I]) { Console. WriteLine (" {0} ", the item). } } CodePudding user response:
Dic [1] is your list1 Dic [2] is your list2 CodePudding user response:
The big watermelon a WuYiJin reference 1 floor? Response: int i=1; If (dic) either ContainsKey (I)) { Foreach (var item dic in [I]) { Console. WriteLine (" {0} ", the item). } } Thank you, solved CodePudding user response:
refer to the second floor is nu month god reply: dic [1] is your list1 Dic [2] is your list2 I know, my question is how to get to via the keys of the dictionary to read out the corresponding list CodePudding user response:
reference 4 floor Sunnyonion response: Quote: refer to the second floor is nu month god reply: Dic [1] is your list1 Dic [2] is your list2 I know, my question is how to get to via the keys of the dictionary to read out the corresponding list ,,,,,, dic [1], this is your key, You dic. The add (1, XXX) Dic. The add (2, XXX) has set itself as the key of 1, 2, CodePudding user response:
Dictionary Dic=new Dictionary (a); Foreach (int key in dic. Keys) { //key is of type int, you the keys of the dictionary //value is the value of the corresponding key, namely list [key]; var value=https://bbs.csdn.net/topics/dic } CodePudding user response:
reference 5 floor is nu month god reply: Quote: refer to 4th floor Sunnyonion response: Quote: refer to the second floor is nu month god reply: Dic [1] is your list1 Dic [2] is your list2 I know, my question is how to get to via the keys of the dictionary to read out the corresponding list ,,,,,, dic [1], this is your key, You dic. The add (1, XXX) Dic. The add (XXX) 2, 1, 2, as the key, they have set Anyway thank you for your reply, that you all know my own set, how could I don't know that, I don't because the output value of the embodiment of the Before I write so Foreach (var item in dic. Keys) { Console. WriteLine (" {0} ", dic [I]); } Output has a problem, get to the problem I have encountered on the second floor, you see how the answer on the second floor, the overall or Thank elder answer and communication CodePudding user response:
refer to 6th floor however reply: Dictionary Dic=new Dictionary (a); Foreach (int key in dic. Keys) { //key is of type int, you the keys of the dictionary //value is the value of the corresponding key, namely list [key]; var value=https://bbs.csdn.net/topics/dic } Oh, at first I was like you wrote the output has a problem, you can see the output on the second floor, that is correct CodePudding user response:
refer to the eighth floor Sunnyonion response: Quote: refer to the sixth floor big though response: Dictionary Dic=new Dictionary (a); Foreach (int key in dic. Keys) { //key is of type int, you the keys of the dictionary //value is the value of the corresponding key, namely list [key]; var value=https://bbs.csdn.net/topics/dic } Oh, at first I was like you wrote the output has a problem, you can see the output on the second floor, that is the correct [key]; var value=https://bbs.csdn.net/topics/dic I'm just, for example, the var value=https://bbs.csdn.net/topics/dic [key]; This value is the value of the dictionary, you what it is when you define your dictionary types, the value is what type, you defined in the thesis is a list , so the var value=dic [key]; This is equivalent to a list value=dic [key], a list is not directly the console. Write out, do you want to loop, that is, Dictionary Dic=new Dictionary (a); Foreach (int key in dic. Keys) { //key is of type int, you the keys of the dictionary //value is the value of the corresponding key, namely list [key]; var value=https://bbs.csdn.net/topics/dic Foreach (string v in value) { The console. Write (v); } } CodePudding user response:
big however, 9/f, reference response: Quote: refer to the eighth floor Sunnyonion response: Quote: refer to the sixth floor big though response: Dictionary Dic=new Dictionary (a); Foreach (int key in dic. Keys) { //key is of type int, you the keys of the dictionary //value is the value of the corresponding key, namely list [key]; var value=https://bbs.csdn.net/topics/dic } Oh, at first I was like you wrote the output has a problem, you can see the output on the second floor, that is the correct [key]; var value=https://bbs.csdn.net/topics/dic I'm just, for example, the var value=https://bbs.csdn.net/topics/dic [key]; This value is the value of the dictionary, you what it is when you define your dictionary types, the value is what type, you defined in the thesis is a list , so the var value=dic [key]; nullnullnullnullnullnullnullnullnullnullnullnullnullnullnull