c# :A dictionary of string and list inside a dictionary of string and dictionary [duplicate]
This question already has an answer here:
Can't add keyValuePair directly to Dictionary
8 answers
I want to create a Dictionary of <string, Dictionary>
type where the inner Dictionary is of type <string, List<string>>
.
I wrote the following code for that :
using System.IO ;
using System.Collections ;
using System.Collections.Generic ;
class nm {
public static void Main () {
Dictionary<string, Dictionary<string, List<string>>> dicdic = new Dictionary<string, Dictionary<string, List<string>>>();
Dictionary<string, List<string>> fr = new Dictionary<string, List<string>>();
Dictionary<string, List<string>> subdicdic = new Dictionary <string , List<string>>() ;
List<string> p = new List<string>();
p.Add("bro, you feel me ") ;
subdicdic.Add(new KeyValuePair<string, List<string>>("ll", p));
fr.Add(new KeyValuePair("foo", subdicdic)) ;
}
}
But on trying to compile it with csc in windows command prompt , I am getting a compilation error at line 18 which is the following :
fr.Add(new KeyValuePair("foo", subdicdic)) ;
stating the following :
"No overload for method 'Add' takes '1' arguments "
I surfed up for similar questions on c# and I got the following question :
Why am i getting "No overload method for Add takes 1 argument" when adding a Dictionary to a List of Dictionaries
But after going through this I am getting a feel there might be some restriction for using list variable name in place of the list . But I am not sure .
I went through the following question too :
Adding a key value pair in a dictionary inside a dictionary
Although the above might help in getting an alternative solution for the purpose code that I am trying to write .
But for now I want to know what stops me from adding this list as a value for the dictionary .
The version details of my compiler :
Microsoft (R) Visual C# 2005 Compiler version 8.00.50727.8922
for Microsoft (R) Windows (R) 2005 Framework version 2.0.50727
What might be the issue here ?
How to operate with a dictionary having an internal dictionary with list in .net 2.0 ?
c# dictionary
marked as duplicate by John Wu
StackExchange.ready(function() {
if (StackExchange.options.isMobile) return;
$('.dupe-hammer-message-hover:not(.hover-bound)').each(function() {
var $hover = $(this).addClass('hover-bound'),
$msg = $hover.siblings('.dupe-hammer-message');
$hover.hover(
function() {
$hover.showInfoMessage('', {
messageElement: $msg.clone().show(),
transient: false,
position: { my: 'bottom left', at: 'top center', offsetTop: -7 },
dismissable: false,
relativeToBody: true
});
},
function() {
StackExchange.helpers.removeMessages();
}
);
});
});
Nov 21 '18 at 23:16
This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.
add a comment |
This question already has an answer here:
Can't add keyValuePair directly to Dictionary
8 answers
I want to create a Dictionary of <string, Dictionary>
type where the inner Dictionary is of type <string, List<string>>
.
I wrote the following code for that :
using System.IO ;
using System.Collections ;
using System.Collections.Generic ;
class nm {
public static void Main () {
Dictionary<string, Dictionary<string, List<string>>> dicdic = new Dictionary<string, Dictionary<string, List<string>>>();
Dictionary<string, List<string>> fr = new Dictionary<string, List<string>>();
Dictionary<string, List<string>> subdicdic = new Dictionary <string , List<string>>() ;
List<string> p = new List<string>();
p.Add("bro, you feel me ") ;
subdicdic.Add(new KeyValuePair<string, List<string>>("ll", p));
fr.Add(new KeyValuePair("foo", subdicdic)) ;
}
}
But on trying to compile it with csc in windows command prompt , I am getting a compilation error at line 18 which is the following :
fr.Add(new KeyValuePair("foo", subdicdic)) ;
stating the following :
"No overload for method 'Add' takes '1' arguments "
I surfed up for similar questions on c# and I got the following question :
Why am i getting "No overload method for Add takes 1 argument" when adding a Dictionary to a List of Dictionaries
But after going through this I am getting a feel there might be some restriction for using list variable name in place of the list . But I am not sure .
I went through the following question too :
Adding a key value pair in a dictionary inside a dictionary
Although the above might help in getting an alternative solution for the purpose code that I am trying to write .
But for now I want to know what stops me from adding this list as a value for the dictionary .
The version details of my compiler :
Microsoft (R) Visual C# 2005 Compiler version 8.00.50727.8922
for Microsoft (R) Windows (R) 2005 Framework version 2.0.50727
What might be the issue here ?
How to operate with a dictionary having an internal dictionary with list in .net 2.0 ?
c# dictionary
marked as duplicate by John Wu
StackExchange.ready(function() {
if (StackExchange.options.isMobile) return;
$('.dupe-hammer-message-hover:not(.hover-bound)').each(function() {
var $hover = $(this).addClass('hover-bound'),
$msg = $hover.siblings('.dupe-hammer-message');
$hover.hover(
function() {
$hover.showInfoMessage('', {
messageElement: $msg.clone().show(),
transient: false,
position: { my: 'bottom left', at: 'top center', offsetTop: -7 },
dismissable: false,
relativeToBody: true
});
},
function() {
StackExchange.helpers.removeMessages();
}
);
});
});
Nov 21 '18 at 23:16
This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.
You say in your question you want two layers:string, dictionary
where the dictionary is astring, List<string>
. But in your code you have 3 layers. Is this on purpose?
– Jonathan
Nov 21 '18 at 23:08
@jonathan :Did not get you.All I waned is to have a dictionary of type <string ,dictionary> and the inner dictionary is of type <string ,List<string>>
– kshiteez bizalom
Nov 21 '18 at 23:23
Have you considered actually making a class to hold your dictionary value? Dictionaries of dictionaries get a bit ridiculous after a point, and we are pst that point here.
– theMayer
Nov 22 '18 at 0:17
add a comment |
This question already has an answer here:
Can't add keyValuePair directly to Dictionary
8 answers
I want to create a Dictionary of <string, Dictionary>
type where the inner Dictionary is of type <string, List<string>>
.
I wrote the following code for that :
using System.IO ;
using System.Collections ;
using System.Collections.Generic ;
class nm {
public static void Main () {
Dictionary<string, Dictionary<string, List<string>>> dicdic = new Dictionary<string, Dictionary<string, List<string>>>();
Dictionary<string, List<string>> fr = new Dictionary<string, List<string>>();
Dictionary<string, List<string>> subdicdic = new Dictionary <string , List<string>>() ;
List<string> p = new List<string>();
p.Add("bro, you feel me ") ;
subdicdic.Add(new KeyValuePair<string, List<string>>("ll", p));
fr.Add(new KeyValuePair("foo", subdicdic)) ;
}
}
But on trying to compile it with csc in windows command prompt , I am getting a compilation error at line 18 which is the following :
fr.Add(new KeyValuePair("foo", subdicdic)) ;
stating the following :
"No overload for method 'Add' takes '1' arguments "
I surfed up for similar questions on c# and I got the following question :
Why am i getting "No overload method for Add takes 1 argument" when adding a Dictionary to a List of Dictionaries
But after going through this I am getting a feel there might be some restriction for using list variable name in place of the list . But I am not sure .
I went through the following question too :
Adding a key value pair in a dictionary inside a dictionary
Although the above might help in getting an alternative solution for the purpose code that I am trying to write .
But for now I want to know what stops me from adding this list as a value for the dictionary .
The version details of my compiler :
Microsoft (R) Visual C# 2005 Compiler version 8.00.50727.8922
for Microsoft (R) Windows (R) 2005 Framework version 2.0.50727
What might be the issue here ?
How to operate with a dictionary having an internal dictionary with list in .net 2.0 ?
c# dictionary
This question already has an answer here:
Can't add keyValuePair directly to Dictionary
8 answers
I want to create a Dictionary of <string, Dictionary>
type where the inner Dictionary is of type <string, List<string>>
.
I wrote the following code for that :
using System.IO ;
using System.Collections ;
using System.Collections.Generic ;
class nm {
public static void Main () {
Dictionary<string, Dictionary<string, List<string>>> dicdic = new Dictionary<string, Dictionary<string, List<string>>>();
Dictionary<string, List<string>> fr = new Dictionary<string, List<string>>();
Dictionary<string, List<string>> subdicdic = new Dictionary <string , List<string>>() ;
List<string> p = new List<string>();
p.Add("bro, you feel me ") ;
subdicdic.Add(new KeyValuePair<string, List<string>>("ll", p));
fr.Add(new KeyValuePair("foo", subdicdic)) ;
}
}
But on trying to compile it with csc in windows command prompt , I am getting a compilation error at line 18 which is the following :
fr.Add(new KeyValuePair("foo", subdicdic)) ;
stating the following :
"No overload for method 'Add' takes '1' arguments "
I surfed up for similar questions on c# and I got the following question :
Why am i getting "No overload method for Add takes 1 argument" when adding a Dictionary to a List of Dictionaries
But after going through this I am getting a feel there might be some restriction for using list variable name in place of the list . But I am not sure .
I went through the following question too :
Adding a key value pair in a dictionary inside a dictionary
Although the above might help in getting an alternative solution for the purpose code that I am trying to write .
But for now I want to know what stops me from adding this list as a value for the dictionary .
The version details of my compiler :
Microsoft (R) Visual C# 2005 Compiler version 8.00.50727.8922
for Microsoft (R) Windows (R) 2005 Framework version 2.0.50727
What might be the issue here ?
How to operate with a dictionary having an internal dictionary with list in .net 2.0 ?
This question already has an answer here:
Can't add keyValuePair directly to Dictionary
8 answers
c# dictionary
c# dictionary
edited Nov 21 '18 at 23:38
kshiteez bizalom
asked Nov 21 '18 at 22:50
kshiteez bizalomkshiteez bizalom
15
15
marked as duplicate by John Wu
StackExchange.ready(function() {
if (StackExchange.options.isMobile) return;
$('.dupe-hammer-message-hover:not(.hover-bound)').each(function() {
var $hover = $(this).addClass('hover-bound'),
$msg = $hover.siblings('.dupe-hammer-message');
$hover.hover(
function() {
$hover.showInfoMessage('', {
messageElement: $msg.clone().show(),
transient: false,
position: { my: 'bottom left', at: 'top center', offsetTop: -7 },
dismissable: false,
relativeToBody: true
});
},
function() {
StackExchange.helpers.removeMessages();
}
);
});
});
Nov 21 '18 at 23:16
This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.
marked as duplicate by John Wu
StackExchange.ready(function() {
if (StackExchange.options.isMobile) return;
$('.dupe-hammer-message-hover:not(.hover-bound)').each(function() {
var $hover = $(this).addClass('hover-bound'),
$msg = $hover.siblings('.dupe-hammer-message');
$hover.hover(
function() {
$hover.showInfoMessage('', {
messageElement: $msg.clone().show(),
transient: false,
position: { my: 'bottom left', at: 'top center', offsetTop: -7 },
dismissable: false,
relativeToBody: true
});
},
function() {
StackExchange.helpers.removeMessages();
}
);
});
});
Nov 21 '18 at 23:16
This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.
You say in your question you want two layers:string, dictionary
where the dictionary is astring, List<string>
. But in your code you have 3 layers. Is this on purpose?
– Jonathan
Nov 21 '18 at 23:08
@jonathan :Did not get you.All I waned is to have a dictionary of type <string ,dictionary> and the inner dictionary is of type <string ,List<string>>
– kshiteez bizalom
Nov 21 '18 at 23:23
Have you considered actually making a class to hold your dictionary value? Dictionaries of dictionaries get a bit ridiculous after a point, and we are pst that point here.
– theMayer
Nov 22 '18 at 0:17
add a comment |
You say in your question you want two layers:string, dictionary
where the dictionary is astring, List<string>
. But in your code you have 3 layers. Is this on purpose?
– Jonathan
Nov 21 '18 at 23:08
@jonathan :Did not get you.All I waned is to have a dictionary of type <string ,dictionary> and the inner dictionary is of type <string ,List<string>>
– kshiteez bizalom
Nov 21 '18 at 23:23
Have you considered actually making a class to hold your dictionary value? Dictionaries of dictionaries get a bit ridiculous after a point, and we are pst that point here.
– theMayer
Nov 22 '18 at 0:17
You say in your question you want two layers:
string, dictionary
where the dictionary is a string, List<string>
. But in your code you have 3 layers. Is this on purpose?– Jonathan
Nov 21 '18 at 23:08
You say in your question you want two layers:
string, dictionary
where the dictionary is a string, List<string>
. But in your code you have 3 layers. Is this on purpose?– Jonathan
Nov 21 '18 at 23:08
@jonathan :Did not get you.All I waned is to have a dictionary of type <string ,dictionary> and the inner dictionary is of type <string ,List<string>>
– kshiteez bizalom
Nov 21 '18 at 23:23
@jonathan :Did not get you.All I waned is to have a dictionary of type <string ,dictionary> and the inner dictionary is of type <string ,List<string>>
– kshiteez bizalom
Nov 21 '18 at 23:23
Have you considered actually making a class to hold your dictionary value? Dictionaries of dictionaries get a bit ridiculous after a point, and we are pst that point here.
– theMayer
Nov 22 '18 at 0:17
Have you considered actually making a class to hold your dictionary value? Dictionaries of dictionaries get a bit ridiculous after a point, and we are pst that point here.
– theMayer
Nov 22 '18 at 0:17
add a comment |
2 Answers
2
active
oldest
votes
The short answer, you are trying to use an overload of a method that does not exist.
The Add
method on a the Dictionary<T1, T2>
class does not support passing in a KeyValuePair<T1, T2>
directly. The only pattern available via the Add
method is Add(T1 key, T2 value);
.
You need to change this line: subdicdic.Add(new KeyValuePair<string, List<string>>("ll", p));
to subdicdic.Add("ll", p);
I should note that you will experience the exact same issue on the very next line and will need to make a similar adjustment.
For your reference, I have created a working .NET Fiddle example of this problem.
c#dictdict.cs(19,58): error CS1502: The best overloaded method match for 'System.Collections.Generic.Dictionary<string,System.Collections.Generic.List<string>>.Add(string, System.Collections.Generic.List<string>)' has some invalid arguments c#dictdict.cs(19,73): error CS1503: Argument '2': cannot convert from 'System.Collections.Generic.Dictionary<string,System.Collections.Generic.List<string>>' to 'System.Collections.Generic.List<string>'
– kshiteez bizalom
Nov 21 '18 at 23:16
I updated my answer with a working .NET Fiddle of your problem. Your issue is because you are trying to add subdic to your fr collection. That is not correct. You need to add it to the dicdic collection.
– Shawn Lehner
Nov 22 '18 at 0:13
add a comment |
Did you try this way:
using System.IO;
using System.Collections;
using System.Collections.Generic;
class nm
{
public static void Main()
{
var dicdic = new Dictionary<string, Dictionary<string, List<string>>>();
var subdicdic = new Dictionary<string, List<string>>();
var p = new List<string>();
p.Add("bro, you feel me ");
subdicdic.Add("ll", p);
dicdic.Add("foo", subdicdic);
}
}
c#dictdict.cs(19,58): error CS1502: The best overloaded method match for 'System.Collections.Generic.Dictionary<string,System.Collections.Generic.List<string>>.Add(string, System.Collections.Generic.List<string>)' has some invalid arguments c#dictdict.cs(19,73): error CS1503: Argument '2': cannot convert from 'System.Collections.Generic.Dictionary<string,System.Collections.Generic.List<string>>' to 'System.Collections.Generic.List<string>'
– kshiteez bizalom
Nov 21 '18 at 23:15
It seems working for me. When I use 'dicdic["foo"]["ll"].IndexOf("bro, you feel me ")' i get 0 which is the index of the string in list p.
– kara
Nov 21 '18 at 23:25
Could you give a pastebin link to your code ?
– kshiteez bizalom
Nov 21 '18 at 23:28
Sure: pastebin.com/k6QV9bMt
– kara
Nov 21 '18 at 23:32
var is throwing compilation error as I have .net 2.0
– kshiteez bizalom
Nov 21 '18 at 23:35
|
show 7 more comments
2 Answers
2
active
oldest
votes
2 Answers
2
active
oldest
votes
active
oldest
votes
active
oldest
votes
The short answer, you are trying to use an overload of a method that does not exist.
The Add
method on a the Dictionary<T1, T2>
class does not support passing in a KeyValuePair<T1, T2>
directly. The only pattern available via the Add
method is Add(T1 key, T2 value);
.
You need to change this line: subdicdic.Add(new KeyValuePair<string, List<string>>("ll", p));
to subdicdic.Add("ll", p);
I should note that you will experience the exact same issue on the very next line and will need to make a similar adjustment.
For your reference, I have created a working .NET Fiddle example of this problem.
c#dictdict.cs(19,58): error CS1502: The best overloaded method match for 'System.Collections.Generic.Dictionary<string,System.Collections.Generic.List<string>>.Add(string, System.Collections.Generic.List<string>)' has some invalid arguments c#dictdict.cs(19,73): error CS1503: Argument '2': cannot convert from 'System.Collections.Generic.Dictionary<string,System.Collections.Generic.List<string>>' to 'System.Collections.Generic.List<string>'
– kshiteez bizalom
Nov 21 '18 at 23:16
I updated my answer with a working .NET Fiddle of your problem. Your issue is because you are trying to add subdic to your fr collection. That is not correct. You need to add it to the dicdic collection.
– Shawn Lehner
Nov 22 '18 at 0:13
add a comment |
The short answer, you are trying to use an overload of a method that does not exist.
The Add
method on a the Dictionary<T1, T2>
class does not support passing in a KeyValuePair<T1, T2>
directly. The only pattern available via the Add
method is Add(T1 key, T2 value);
.
You need to change this line: subdicdic.Add(new KeyValuePair<string, List<string>>("ll", p));
to subdicdic.Add("ll", p);
I should note that you will experience the exact same issue on the very next line and will need to make a similar adjustment.
For your reference, I have created a working .NET Fiddle example of this problem.
c#dictdict.cs(19,58): error CS1502: The best overloaded method match for 'System.Collections.Generic.Dictionary<string,System.Collections.Generic.List<string>>.Add(string, System.Collections.Generic.List<string>)' has some invalid arguments c#dictdict.cs(19,73): error CS1503: Argument '2': cannot convert from 'System.Collections.Generic.Dictionary<string,System.Collections.Generic.List<string>>' to 'System.Collections.Generic.List<string>'
– kshiteez bizalom
Nov 21 '18 at 23:16
I updated my answer with a working .NET Fiddle of your problem. Your issue is because you are trying to add subdic to your fr collection. That is not correct. You need to add it to the dicdic collection.
– Shawn Lehner
Nov 22 '18 at 0:13
add a comment |
The short answer, you are trying to use an overload of a method that does not exist.
The Add
method on a the Dictionary<T1, T2>
class does not support passing in a KeyValuePair<T1, T2>
directly. The only pattern available via the Add
method is Add(T1 key, T2 value);
.
You need to change this line: subdicdic.Add(new KeyValuePair<string, List<string>>("ll", p));
to subdicdic.Add("ll", p);
I should note that you will experience the exact same issue on the very next line and will need to make a similar adjustment.
For your reference, I have created a working .NET Fiddle example of this problem.
The short answer, you are trying to use an overload of a method that does not exist.
The Add
method on a the Dictionary<T1, T2>
class does not support passing in a KeyValuePair<T1, T2>
directly. The only pattern available via the Add
method is Add(T1 key, T2 value);
.
You need to change this line: subdicdic.Add(new KeyValuePair<string, List<string>>("ll", p));
to subdicdic.Add("ll", p);
I should note that you will experience the exact same issue on the very next line and will need to make a similar adjustment.
For your reference, I have created a working .NET Fiddle example of this problem.
edited Nov 22 '18 at 0:12
answered Nov 21 '18 at 23:06
Shawn LehnerShawn Lehner
1,260712
1,260712
c#dictdict.cs(19,58): error CS1502: The best overloaded method match for 'System.Collections.Generic.Dictionary<string,System.Collections.Generic.List<string>>.Add(string, System.Collections.Generic.List<string>)' has some invalid arguments c#dictdict.cs(19,73): error CS1503: Argument '2': cannot convert from 'System.Collections.Generic.Dictionary<string,System.Collections.Generic.List<string>>' to 'System.Collections.Generic.List<string>'
– kshiteez bizalom
Nov 21 '18 at 23:16
I updated my answer with a working .NET Fiddle of your problem. Your issue is because you are trying to add subdic to your fr collection. That is not correct. You need to add it to the dicdic collection.
– Shawn Lehner
Nov 22 '18 at 0:13
add a comment |
c#dictdict.cs(19,58): error CS1502: The best overloaded method match for 'System.Collections.Generic.Dictionary<string,System.Collections.Generic.List<string>>.Add(string, System.Collections.Generic.List<string>)' has some invalid arguments c#dictdict.cs(19,73): error CS1503: Argument '2': cannot convert from 'System.Collections.Generic.Dictionary<string,System.Collections.Generic.List<string>>' to 'System.Collections.Generic.List<string>'
– kshiteez bizalom
Nov 21 '18 at 23:16
I updated my answer with a working .NET Fiddle of your problem. Your issue is because you are trying to add subdic to your fr collection. That is not correct. You need to add it to the dicdic collection.
– Shawn Lehner
Nov 22 '18 at 0:13
c#dictdict.cs(19,58): error CS1502: The best overloaded method match for 'System.Collections.Generic.Dictionary<string,System.Collections.Generic.List<string>>.Add(string, System.Collections.Generic.List<string>)' has some invalid arguments c#dictdict.cs(19,73): error CS1503: Argument '2': cannot convert from 'System.Collections.Generic.Dictionary<string,System.Collections.Generic.List<string>>' to 'System.Collections.Generic.List<string>'
– kshiteez bizalom
Nov 21 '18 at 23:16
c#dictdict.cs(19,58): error CS1502: The best overloaded method match for 'System.Collections.Generic.Dictionary<string,System.Collections.Generic.List<string>>.Add(string, System.Collections.Generic.List<string>)' has some invalid arguments c#dictdict.cs(19,73): error CS1503: Argument '2': cannot convert from 'System.Collections.Generic.Dictionary<string,System.Collections.Generic.List<string>>' to 'System.Collections.Generic.List<string>'
– kshiteez bizalom
Nov 21 '18 at 23:16
I updated my answer with a working .NET Fiddle of your problem. Your issue is because you are trying to add subdic to your fr collection. That is not correct. You need to add it to the dicdic collection.
– Shawn Lehner
Nov 22 '18 at 0:13
I updated my answer with a working .NET Fiddle of your problem. Your issue is because you are trying to add subdic to your fr collection. That is not correct. You need to add it to the dicdic collection.
– Shawn Lehner
Nov 22 '18 at 0:13
add a comment |
Did you try this way:
using System.IO;
using System.Collections;
using System.Collections.Generic;
class nm
{
public static void Main()
{
var dicdic = new Dictionary<string, Dictionary<string, List<string>>>();
var subdicdic = new Dictionary<string, List<string>>();
var p = new List<string>();
p.Add("bro, you feel me ");
subdicdic.Add("ll", p);
dicdic.Add("foo", subdicdic);
}
}
c#dictdict.cs(19,58): error CS1502: The best overloaded method match for 'System.Collections.Generic.Dictionary<string,System.Collections.Generic.List<string>>.Add(string, System.Collections.Generic.List<string>)' has some invalid arguments c#dictdict.cs(19,73): error CS1503: Argument '2': cannot convert from 'System.Collections.Generic.Dictionary<string,System.Collections.Generic.List<string>>' to 'System.Collections.Generic.List<string>'
– kshiteez bizalom
Nov 21 '18 at 23:15
It seems working for me. When I use 'dicdic["foo"]["ll"].IndexOf("bro, you feel me ")' i get 0 which is the index of the string in list p.
– kara
Nov 21 '18 at 23:25
Could you give a pastebin link to your code ?
– kshiteez bizalom
Nov 21 '18 at 23:28
Sure: pastebin.com/k6QV9bMt
– kara
Nov 21 '18 at 23:32
var is throwing compilation error as I have .net 2.0
– kshiteez bizalom
Nov 21 '18 at 23:35
|
show 7 more comments
Did you try this way:
using System.IO;
using System.Collections;
using System.Collections.Generic;
class nm
{
public static void Main()
{
var dicdic = new Dictionary<string, Dictionary<string, List<string>>>();
var subdicdic = new Dictionary<string, List<string>>();
var p = new List<string>();
p.Add("bro, you feel me ");
subdicdic.Add("ll", p);
dicdic.Add("foo", subdicdic);
}
}
c#dictdict.cs(19,58): error CS1502: The best overloaded method match for 'System.Collections.Generic.Dictionary<string,System.Collections.Generic.List<string>>.Add(string, System.Collections.Generic.List<string>)' has some invalid arguments c#dictdict.cs(19,73): error CS1503: Argument '2': cannot convert from 'System.Collections.Generic.Dictionary<string,System.Collections.Generic.List<string>>' to 'System.Collections.Generic.List<string>'
– kshiteez bizalom
Nov 21 '18 at 23:15
It seems working for me. When I use 'dicdic["foo"]["ll"].IndexOf("bro, you feel me ")' i get 0 which is the index of the string in list p.
– kara
Nov 21 '18 at 23:25
Could you give a pastebin link to your code ?
– kshiteez bizalom
Nov 21 '18 at 23:28
Sure: pastebin.com/k6QV9bMt
– kara
Nov 21 '18 at 23:32
var is throwing compilation error as I have .net 2.0
– kshiteez bizalom
Nov 21 '18 at 23:35
|
show 7 more comments
Did you try this way:
using System.IO;
using System.Collections;
using System.Collections.Generic;
class nm
{
public static void Main()
{
var dicdic = new Dictionary<string, Dictionary<string, List<string>>>();
var subdicdic = new Dictionary<string, List<string>>();
var p = new List<string>();
p.Add("bro, you feel me ");
subdicdic.Add("ll", p);
dicdic.Add("foo", subdicdic);
}
}
Did you try this way:
using System.IO;
using System.Collections;
using System.Collections.Generic;
class nm
{
public static void Main()
{
var dicdic = new Dictionary<string, Dictionary<string, List<string>>>();
var subdicdic = new Dictionary<string, List<string>>();
var p = new List<string>();
p.Add("bro, you feel me ");
subdicdic.Add("ll", p);
dicdic.Add("foo", subdicdic);
}
}
answered Nov 21 '18 at 23:11
karakara
576
576
c#dictdict.cs(19,58): error CS1502: The best overloaded method match for 'System.Collections.Generic.Dictionary<string,System.Collections.Generic.List<string>>.Add(string, System.Collections.Generic.List<string>)' has some invalid arguments c#dictdict.cs(19,73): error CS1503: Argument '2': cannot convert from 'System.Collections.Generic.Dictionary<string,System.Collections.Generic.List<string>>' to 'System.Collections.Generic.List<string>'
– kshiteez bizalom
Nov 21 '18 at 23:15
It seems working for me. When I use 'dicdic["foo"]["ll"].IndexOf("bro, you feel me ")' i get 0 which is the index of the string in list p.
– kara
Nov 21 '18 at 23:25
Could you give a pastebin link to your code ?
– kshiteez bizalom
Nov 21 '18 at 23:28
Sure: pastebin.com/k6QV9bMt
– kara
Nov 21 '18 at 23:32
var is throwing compilation error as I have .net 2.0
– kshiteez bizalom
Nov 21 '18 at 23:35
|
show 7 more comments
c#dictdict.cs(19,58): error CS1502: The best overloaded method match for 'System.Collections.Generic.Dictionary<string,System.Collections.Generic.List<string>>.Add(string, System.Collections.Generic.List<string>)' has some invalid arguments c#dictdict.cs(19,73): error CS1503: Argument '2': cannot convert from 'System.Collections.Generic.Dictionary<string,System.Collections.Generic.List<string>>' to 'System.Collections.Generic.List<string>'
– kshiteez bizalom
Nov 21 '18 at 23:15
It seems working for me. When I use 'dicdic["foo"]["ll"].IndexOf("bro, you feel me ")' i get 0 which is the index of the string in list p.
– kara
Nov 21 '18 at 23:25
Could you give a pastebin link to your code ?
– kshiteez bizalom
Nov 21 '18 at 23:28
Sure: pastebin.com/k6QV9bMt
– kara
Nov 21 '18 at 23:32
var is throwing compilation error as I have .net 2.0
– kshiteez bizalom
Nov 21 '18 at 23:35
c#dictdict.cs(19,58): error CS1502: The best overloaded method match for 'System.Collections.Generic.Dictionary<string,System.Collections.Generic.List<string>>.Add(string, System.Collections.Generic.List<string>)' has some invalid arguments c#dictdict.cs(19,73): error CS1503: Argument '2': cannot convert from 'System.Collections.Generic.Dictionary<string,System.Collections.Generic.List<string>>' to 'System.Collections.Generic.List<string>'
– kshiteez bizalom
Nov 21 '18 at 23:15
c#dictdict.cs(19,58): error CS1502: The best overloaded method match for 'System.Collections.Generic.Dictionary<string,System.Collections.Generic.List<string>>.Add(string, System.Collections.Generic.List<string>)' has some invalid arguments c#dictdict.cs(19,73): error CS1503: Argument '2': cannot convert from 'System.Collections.Generic.Dictionary<string,System.Collections.Generic.List<string>>' to 'System.Collections.Generic.List<string>'
– kshiteez bizalom
Nov 21 '18 at 23:15
It seems working for me. When I use 'dicdic["foo"]["ll"].IndexOf("bro, you feel me ")' i get 0 which is the index of the string in list p.
– kara
Nov 21 '18 at 23:25
It seems working for me. When I use 'dicdic["foo"]["ll"].IndexOf("bro, you feel me ")' i get 0 which is the index of the string in list p.
– kara
Nov 21 '18 at 23:25
Could you give a pastebin link to your code ?
– kshiteez bizalom
Nov 21 '18 at 23:28
Could you give a pastebin link to your code ?
– kshiteez bizalom
Nov 21 '18 at 23:28
Sure: pastebin.com/k6QV9bMt
– kara
Nov 21 '18 at 23:32
Sure: pastebin.com/k6QV9bMt
– kara
Nov 21 '18 at 23:32
var is throwing compilation error as I have .net 2.0
– kshiteez bizalom
Nov 21 '18 at 23:35
var is throwing compilation error as I have .net 2.0
– kshiteez bizalom
Nov 21 '18 at 23:35
|
show 7 more comments
You say in your question you want two layers:
string, dictionary
where the dictionary is astring, List<string>
. But in your code you have 3 layers. Is this on purpose?– Jonathan
Nov 21 '18 at 23:08
@jonathan :Did not get you.All I waned is to have a dictionary of type <string ,dictionary> and the inner dictionary is of type <string ,List<string>>
– kshiteez bizalom
Nov 21 '18 at 23:23
Have you considered actually making a class to hold your dictionary value? Dictionaries of dictionaries get a bit ridiculous after a point, and we are pst that point here.
– theMayer
Nov 22 '18 at 0:17