Generic type conversion FROM string

前端 未结 11 662
终归单人心
终归单人心 2020-11-27 09:47

I have a class that I want to use to store \"properties\" for another class. These properties simply have a name and a value. Ideally, what I would like is to be able to add

11条回答
  •  孤独总比滥情好
    2020-11-27 09:53

    TypeDescriptor.GetConverter(PropertyObject).ConvertFrom(Value)
    

    TypeDescriptor is class having method GetConvertor which accept a Type object and then you can call ConvertFrom method to convert the value for that specified object.

提交回复
热议问题