In addition to using LINQ, if you're on .NET 4 this is possible using dynamic:
static T Add(T x, T y)
{
dynamic dx = x, dy = y;
return dx + dy;
}
In your code sample this turns into:
public class NumberContainer where T: struct
{
public T ValueA { get; private set; }
public T ValueB { get; private set; }
public T Total { get { return ((dynamic)ValueA) + ((dynamic)ValueB); } }
}
This approach doesn't ensure safety though. If T is some random struct that doesn't support + you'll end up with an exception (I think).