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?
Add this line after creating the dictionary:
String value = "";
It looks like the problem is that value isn't properly typed to string. This is the only reason that you would get that particular error. You need to change the type of value to string or declare a new variable of type string to use in TryGetValue
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With