Generic type conversion FROM string

前端 未结 11 629
终归单人心
终归单人心 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:52

    I used lobos answer and it works. But I had a problem with the conversion of doubles because of the culture settings. So I added

    return (T)Convert.ChangeType(base.Value, typeof(T), CultureInfo.InvariantCulture);
    

提交回复
热议问题