accessing operator overloaded class defined in c#

A

Armond VanHeusen

A quick question if I may (this relates to .NET1.1 by the way):

If I have a C# class defined in my project that does operator overloading,
can I use this in my VB code?

For example, I have a c# class called for the sake of argument dummyclass
which has the + operator overloaded.

In C# I can do dummyclass temp = someInstanceofDummyClass1 +
someInstanceofDummyClass1;

When I try to access this in my VB code it tells me that the Operator '+'
has not been defined for types dummyclass.

Am I doing something wrong, or is this something inherent in 1.1?

Cheers!
 
H

Herfried K. Wagner [MVP]

Armond VanHeusen said:
If I have a C# class defined in my project that does operator overloading,
can I use this in my VB code?

Basically yes, but you cannot use the operators directly.
For example, I have a c# class called for the sake of argument dummyclass
which has the + operator overloaded.

In C# I can do dummyclass temp = someInstanceofDummyClass1 +
someInstanceofDummyClass1;

When I try to access this in my VB code it tells me that the Operator '+'
has not been defined for types dummyclass.

Operators are methods with special names.

VB.NET 2002/2003:

\\\
c = wrapInt32.op_Addition(a, b)
///

VB 2005 will support operator overloading, so the code you posted will work
then without using 'op_Addition'.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top