Cast a property to its actual type dynamically using reflection (where actual type is generic)

前端 未结 1 936
滥情空心
滥情空心 2021-01-27 02:00

This is a slightly different question asked here. I modified the same code into my needs like below:

using System;
using System.Collections.Generic;
using System.         


        
相关标签:
1条回答
  • 2021-01-27 02:39

    Change your code to receive property to:

    PropertyInfo propInfo = tester.GetType().GetProperty("MyIntProperty");
    

    So you use constructed generic type.

    0 讨论(0)
提交回复
热议问题