As I stated previously - if you are using .NET 3.5 I can fix this for
you instantly; let me know if this is an option.
If not, it is a major PITA.
Previous post: http://groups.google.com/group/micro...ac16748fa115e5
Marc
This is a discussion on How to use +, -, *, / etc in C# Generic - CSharp ; Question is how to make the following class compile? class foo<T> { private T a, b; public T Sum() { return a + b; // this line does not compile. } } The background is that I want this class ...
Question is how to make the following class compile?
class foo<T>
{
private T a, b;
public T Sum()
{
return a + b; // this line does not compile.
}
}
The background is that I want this class to be instantiated by all the
"numeric friendly" classes (i.e. those support operator like +,
- ...). These should include both built-in types, (e.g. double) and
user defined class.
Thanks.
As I stated previously - if you are using .NET 3.5 I can fix this for
you instantly; let me know if this is an option.
If not, it is a major PITA.
Previous post: http://groups.google.com/group/micro...ac16748fa115e5
Marc
On Fri, 14 Dec 2007 15:39:34 -0800, My interest <myinterest@gmail.com>
wrote:
> Question is how to make the following class compile?
>
> class foo<T>
> {
> private T a, b;
>
> public T Sum()
> {
> return a + b; // this line does not compile.
> }
> }
Didn't we just have this thread? Didn't you start that one too?
Hint: just because the operator is now + instead of *, that doesn't make
it a new question.
On Dec 14, 7:00 pm, "Peter Duniho" <NpOeStPe...@nnowslpianmk.com>
wrote:
> On Fri, 14 Dec 2007 15:39:34 -0800, My interest <myinter...@gmail.com>
> wrote:
>
> > Question is how to make the following class compile?
>
> > class foo<T>
> > {
> > private T a, b;
>
> > public T Sum()
> > {
> > return a + b; // this line does not compile.
> > }
> > }
>
> Didn't we just have this thread? Didn't you start that one too?
>
> Hint: just because the operator is now + instead of *, that doesn't make
> it a new question.
Sorry, this is a repost. My explorer crashed right after I clicked
the Submit button. So I assumed it failed to post. Sorry about the
re-posting.