I want to create a list of anonymous objects. So I did this:
var problematicAddresses = new HashSet<dynamic>();
foreach (DataRow row in dtMeters.Rows)
{
var billingAddress = new
{
address = row["BillingAddress"].ToString(),
city = row["BillingCity"].ToString(),
state = row["BillingState"].ToString(),
zip = row["BillingZip"].ToString()
};
// ... fill problematicAddresses without any problem
foreach (var completeAddress in problematicAddresses)
{
string addr = completeAddress.address;
// ...
}
// ...
}
The last line here doesn’t compile and gives me the following error:
One or more types required to compile a dynamic expression cannot be found. Are you missing references to Microsoft.CSharp.dll and System.Core.dll?
Could you please help me with this?
Thanks.
Make sure you have those libs included … Also, use var instead of string on the last line