Test if Convert.ChangeType will work between two types

后端 未结 4 1171
悲哀的现实
悲哀的现实 2020-12-03 13:44

This is a follow-up to this question about converting values with reflection. Converting an object of a certain type to another type can be done like this:

o         


        
4条回答
  •  夕颜
    夕颜 (楼主)
    2020-12-03 14:06

    I have written a little framework that includes a Convert class that can do more than the System.Convert class. If you are interested in using it, you can download it from Github. It doesn't have the ability to determine if you can convert between values, but that seems like a good feature to add.

    It does include the ability to convert values based on:

    • IConvertible
    • TypeConverters
    • ToXxx methods
    • Parse static methods
    • Parameterized constructor
    • and a few other minor ones

    Data Type Conversions

提交回复
热议问题