Generics And Arithmetic
- From: "Gary Brown" <garyjbrown@xxxxxxxxxxx>
- Date: Sun, 13 Aug 2006 20:21:41 -0400
Hi,
When I do the following
public class IAmAGeneric<T>
{
...
public T AMember (T a, T b) { return a + b; };
}
C# complains that
operator '+' cannot be applied to operands of type 'T' and 'T'
I haven't found any documentation that says this won't work but
I haven't found any that says it will. Nor an example. Is this a
limitation of C# generics? Is there a workaround?
This usage is common in C++ templates. Is this limitation because
C++ templates are like macros and C# generics are like classes
(according to the C# head honcho).
Thanks,
Gary
.
- Follow-Ups:
- Re: Generics And Arithmetic
- From: Gary Brown
- Re: Generics And Arithmetic
- From: Tom Spink
- Re: Generics And Arithmetic
- From: Arne Vajhøj
- Re: Generics And Arithmetic
- From: Carl Daniel [VC++ MVP]
- Re: Generics And Arithmetic
- From: Torben K. Jensen
- Re: Generics And Arithmetic
- Prev by Date: elminate html in string
- Next by Date: Re: Can I store this in app.config?
- Previous by thread: elminate html in string
- Next by thread: Re: Generics And Arithmetic
- Index(es):
Relevant Pages
|