linq c# where condition

C#
var query = MemberTable.Where(x=>x.sex.Equals(Sex))

if (members != null)
     query = query.Where(x=>members.Contains(x.membercode))

//use your query
query.ToList();
Source

Also in C#: