I create the following anonymous object:
var obj = new { Country = countryVal, City = cityVal, Keyword = key, Page = page };
I want to include members in an object only if its value is present.
For example, if cityVal is null, I do not want to add City to the object initialization
var obj = new { Country = countryVal, City = cityVal, // ignore this if cityVal is null
Keyword = key,
Page = page
};
Is this possible in C #?
source share