public class Variable
{
public dynamic value { get; set; }
public string config { get; set; }
public Variable(dynamic value = null, string config = "")
{
this.value = value;
this.config = config;
}
}
public class Teste
{
public Variable teste1 = new Variable(config: "string");
public Variable teste2 = new Variable(config: "string");
public Teste()
{
this.teste1.value = "testando";
this.teste2.value = "testando";
}
}
No exemplo abaixo funciona normalmente:
@Html.Raw(Teste.teste1.value + "<br>" + Teste.teste2.value)
Porém queria pegar de maneira dinâmica
@ {
string[] fields = new string[2] { "teste1", "teste2" };
for (var i = 0; i < fields.Length; i++) {
@Html.Raw(Teste.fields[i].value + "<br>")
}
}
Este é um exemplo rápido que montei, não sei se consegui ser claro, seria possível fazer algo assim?
Obrigado