Folks, in the tiny sample below I want to parse some text and set the
generic value, which will be int, double or long. The highlighted statements
show what I want to do, but how is it done in a generic way?

 

Greg

 

 

public class DemoClass<T> where T : struct

{

    private T value;

 

    public void FromText(string rawValue)

    {

        value = double.Parse(rawValue);

        value = int.Parse(rawValue);

    }

}

 

 

Reply via email to