0

I'm not sure if this is possible, but i'm trying to use a variable as a property while running a foreach. I understand that this approach is probably not deemed clean and is due to poor data modeling, but i'm just wondering if this is possible.

Model

public class nameActivity
{   
    public string name {get;set;};  
    public int month {get;set;};    
    public int hours {get;set;};    
    public int billings {get;set;};     
}

View

string[] stringArray = new string[] { "hours", "billings" };

foreach (string i in stringArray)
{
    foreach (var item in Model)
    {
        <td>@item.name</td>
        <td>@item.month</td>
        <!--somehow use i variable in below td-->
        <td>@item.use_i_here</td>
    }   
}
Daniel A. White
  • 187,200
  • 47
  • 362
  • 445
jellz77
  • 324
  • 4
  • 15

0 Answers0