Surely there's very few types that a) you're using, that b) offer that Parse
method. Could you save the reflection call and simply do something like
if (typeof(T) is decimal) { decimal.Parse(...); }
elseif (typeof(T) is int) { int.Parse(...); }I can't cast a double, int or long to the generic type T which is constrained to be a struct. Hmmm .. why? As David says, if I'm doing if typeof(X) in the class then there's no point in it being generic. The class I'm using is in fact a wrapper around a two-dimensional array of the T (a matrix of T). It just seemed natural to have a generic class to hold the matrix of T values, and it was working lovely until I stumbled upon this brain-teaser of parsing a string to set one of the T values. Greg
<<image001.png>>
