Generic type conversion FROM string

前端 未结 11 631
终归单人心
终归单人心 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 10:03

    public class TypedProperty : Property
    {
        public T TypedValue
        {
            get { return (T)(object)base.Value; }
            set { base.Value = value.ToString();}
        }
    }
    

    I using converting via an object. It is a little bit simpler.

提交回复
热议问题