Hi,
If I have a generic class like this:
public ClassA<T>
{
private T val;
...
}
The T can be some numeric types. Now, if I want to add a constructor, which contains:
val = Math.Pow(2.0);
The compiler will complain "can't implicitly convert 'double' to 'T'". So how to do it correctly here
Thanks in advance,
Shu

Generic: how to cast to the type specified by a type parameter?
Clintonf
cshood
Try it like this
val = (T)Convert.ChangeType(Math.Pow(2.0), typeof(T));
Also, Math.Pow takes two arguments, but that's another issue.