C#遍历对象属性

C#遍历对象属性,在模版中Mdel.yuyue是个对象

<table class="table table-bordered table-hover" id="mytable">
    <thead>
        <tr>
            <th>key</th>
            <th>value</th>
        </tr>
    </thead>
    <tbody>
        @foreach(var pinfo in Model.yuyue.GetType().GetProperties()){
            <tr><td>@pinfo.Name</td><td>@pinfo.GetValue(Model.yuyue,null)</td></tr>
        }
    </tbody>
</table>



你可能感兴趣的:(C#遍历对象属性)