How can i pass a Dictionary to a method that receives a Dictionary?
Dictionary<string,string> dic = new Dictionary<string,string>();
//Call
MyMethod(dic);
public void MyMethod(Dictionary<object, object> dObject){
.........
}
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
You cannot pass it as is, but you can pass a copy:
It is often a good idea to make your API program take an interface rather than a class, like this:
This little change lets you pass dictionaries of other kinds, such as
SortedList<K,T>to your API.