CSVReader: TryGetValue?
Closed this issue · 2 comments
alexlaurence commented
Just wondering how would I implement inline "out string" with TryGetValue?
List<Dictionary<string, object>> data = CSVReader.Read("data");
string phoneNumber = "012345";
if (data.TryGetValue(phoneNumber, out user))
{
Console.WriteLine("{0}, {1}, phone {2}", user.Name, user.Address, user.PhoneNumber);
}
But I get this error for TryGetValue
Error CS1061: 'List<Dictionary<string, object>>' does not contain a definition for 'TryGetValue' and no extension method 'TryGetValue' accepting a first argument of type 'List<Dictionary<string, object>>' could be found (are you missing a using directive or an assembly reference?) (CS1061) (Assembly-CSharp)
tikonen commented
data
is list of dictionaries, access the dictionary of the row you need: data[0].TryGetvalue()
alexlaurence commented
Thanks so much! This solved the issue.