Quantcast
Channel: Visual Studio and Visual Web Developer Express
Viewing all articles
Browse latest Browse all 3509

System.Collections.Generic.Dictionary is not assignable to parameter type ‘System.Collections.Generic.KeyValuePair

$
0
0

Hi!

I am using Dictionary, to store two string key and value pairs.

public void SomeMethod(Model myModel)
{
public Dictionary<string, string> myDictionary = new Dictionary<string, string>();

 foreach(var email in myModel.GetEsEmails)
 {
    myDictionary.Add(email.Id,email.EmailAddress);
 }

 CreateEmailList(myDictionary);

}

Service Method

public void CreateEmailList(List<KeyValuePair<string,string>> emailTo)
{

}


 When I call the service method and pass myDictionary as a parameter.

I get this error like below.
Argument Type ‘System.Collections.Generic.Dictionary<string,string> ‘ is not assignable to parameter type ‘System.Collections.Generic.KeyValuePair<string,string>[]’

Please give suggestions, would I need to do a cast.

Thank you,


Viewing all articles
Browse latest Browse all 3509

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>