Link to home
Start Free TrialLog in
Avatar of Sri
Sri

asked on

Checking for null while converting to Dictionary

Need help in C# 5 replacing value with empty collection for the null ones

    

//Structure of the class Info
public class Info
{
     public IList<string> Type { get; set; }
     public IList<string> Flow { get; set; }
}

//Trying to convert the returned result into dictionary
db.InsertMissingInfo(result.Item1.ToDictionary(k => k.Key, v => new Info { Type = v.Value.Type, Flow = v.Value.Flow  }));

Open in new window


Here result.Item1 is Tuple which i am converting in to dictionary
How can i check if the v.Value.Flow is null here if it is null i want to put an empty collection
ASKER CERTIFIED SOLUTION
Avatar of kaufmed
kaufmed
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Sri
Sri

ASKER

Able to check for null and fix the issue