CSharp · Console
using System;
using System.Dynamic;
using System.Collections.Generic;
public class Program
{
public static void Main()
{
dynamic line = new ExpandoObject();
line.Filial = "";
line.Cidade = "";
line.Cep = "";
line.Uf = "";
line.Cliente = "";
line.Cnpj = "";
var fields = new List<string>() { "Cidade", "Cep", "Uf", "Cliente", "Cnpj", "Filial", "Algum" };
var dicLine = (IDictionary<string, object>)line;
foreach(var f in fields)
{
if (dicLine.ContainsKey(f))
{
dicLine[f] = "teste";
}
}
Console.WriteLine("line.Cep=" + line.Cep);
}
}