C# – The best overloaded method match has some invalid arguments

c

I can't get TryGetValue to work for some reason.

Dictionary<String,String> testdict = new Dictionary<String,String>();
String teststr = "test";
if(testdict.TryGetValue(teststr,out value))
{
    //Ladida
}

Error received:

The best overloaded method match for 'System.Collections.Generic.Dictionary<string,string>.TryGetValue(string, out string)' has some invalid arguments

Can anyone tell me what's wrong with my code?

Best Answer

Add this line after creating the dictionary:

String value = "";
Related Topic