The following code causes a compilation error.

using System;

public class AppRunner
{
 public static void Main()
 {
  SomeMath<int> s = new SomeMath<int>();
  Console.WriteLine(s.Add(1,2));
 }


 private class SomeMath <T>
 {
  public T Add (T val, T val2)
  {
   T ret = val + val2;
   return val;
  }
 }
}

The error is error: CS0019:Operator '+' cannot be applied to operands of type 'T' and 
'T'

it seems to me that the compiler would convert the type reference <T> to int, allowing 
the + operator to work.  Do I now need to overload the + operator?  Is this a bug in 
the compiler, or am I just missing something (very possible)?

Don

Reply via email to