How to create own dynamic type or dynamic object in C#?

前端 未结 7 1395
醉话见心
醉话见心 2020-12-04 08:05

There, is for example, ViewBag property of ControllerBase class and we can dynamically get/set values and add any number of additional fields or properties to t

7条回答
  •  挽巷
    挽巷 (楼主)
    2020-12-04 08:59

     var data = new { studentId = 1, StudentName = "abc" };  
    

    Or value is present

      var data = new { studentId, StudentName };
    

提交回复
热议问题