M
m.a
Hello,
I am developing a class which needs to do some mathematical processing. I
like to develop it in a way that it accept double or float or int based on
the user requirement so I defined it as a generic as follow:
public class MyClass<T>
{
T pi = (T)
3.1415926535897932384626433832795028841971693993751058209749445;
public MyClass()
{
}
}
But I am getting error:
Can not convert double to T.
I defined the class as follow but the error is the same:
public class MyClass<T>
{
T pi;
public MyClass()
{
pi = (T) 3.1415926535897932384626433832795028841971693993751058209749445
}
}
How can I do this?
Any help is very appreciated.
Regards
I am developing a class which needs to do some mathematical processing. I
like to develop it in a way that it accept double or float or int based on
the user requirement so I defined it as a generic as follow:
public class MyClass<T>
{
T pi = (T)
3.1415926535897932384626433832795028841971693993751058209749445;
public MyClass()
{
}
}
But I am getting error:
Can not convert double to T.
I defined the class as follow but the error is the same:
public class MyClass<T>
{
T pi;
public MyClass()
{
pi = (T) 3.1415926535897932384626433832795028841971693993751058209749445
}
}
How can I do this?
Any help is very appreciated.
Regards