Is that not allowed to assume generic type numeric type? As far as I've
tried, I got an error with the following code:
public class AAA<T>
{
public int Foo(T a)
{
return a; // error: Cannot implicitly convert type 'T' to 'int'
}
}
public class BBB
{
public int Goo()
{
int x = 3;
return AAA<int>.Foo(x) ;
}
}
where my intention is to use AAA<on numeric value only, which is
acceptable in C++.
How can I resolve that compilation error? Please reply.
Thanks in advance.
Hyun-jik Bae
tried, I got an error with the following code:
public class AAA<T>
{
public int Foo(T a)
{
return a; // error: Cannot implicitly convert type 'T' to 'int'
}
}
public class BBB
{
public int Goo()
{
int x = 3;
return AAA<int>.Foo(x) ;
}
}
where my intention is to use AAA<on numeric value only, which is
acceptable in C++.
How can I resolve that compilation error? Please reply.
Thanks in advance.
Hyun-jik Bae
Comment