string[] showProperties = {"id", "name"};
@*
user has many properties, id, name, address, etc...
*@
<!-- now I just want to show the properties in the shownProperties list -->
@for (int j = 0; j < showProperties.Length; j++)
{
<td>
@user.showProperties[j]
</td>
}
Normally I would do @user.id
or @user.name to display, but in this case, [property] is dynamically pulled by the value of the array of showColumns.
The @user.showProperties[j] above won't work, Razor won't recognize the id as the property for example. Is there a way to inject 'id' into @user.[] as @user.id?
How do I do @user.(mydynamicproperty)
properly?