3
Answers

how to validate dict in c#

Photo of Narasiman nar

Narasiman nar

7y
1.8k
1
 
 My code as follows
 
int columnindex = 43;
List<string> lst = new List<string>(); 
 
foreach (DataRow row in dtFarmerFarmReports.Rows)
{
 var dict = JsonConvert.DeserializeObject<Dictionary<string, string>>(row["farm_detailsdata"].ToString());
  if (dict!=null && dict!= string.Empty)
    {
      string str = string.Empty;
      lst.AddRange(dict.Keys); 
   } 
 
 when i run shows error as follows
Operator '!=' cannot be applied to operands of type 'Dictionary<string, string>' and 'string' 
 
how to fix this error. 
 
 

Answers (3)