473,471 Members | 2,009 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

accessing operator overloaded class defined in c#

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!
Nov 21 '05 #1
2 1141
"Armond VanHeusen" <av*@klok.com> schrieb:
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'.

--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://classicvb.org/petition/>

Nov 21 '05 #2
thanks for that! And here I thought i was going crazy!!!

"Herfried K. Wagner [MVP]" <hi***************@gmx.at> wrote in message
news:ut**************@TK2MSFTNGP10.phx.gbl...
"Armond VanHeusen" <av*@klok.com> schrieb:
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'.

--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://classicvb.org/petition/>

Nov 21 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

30
by: | last post by:
I have not posted to comp.lang.c++ (or comp.lang.c++.moderated) before. In general when I have a C++ question I look for answers in "The C++ Programming Language, Third Edition" by Stroustrup....
7
by: Nicolay Korslund | last post by:
Hi! I'm having a little trouble with the typecast operator, can anybody help me with the rules for when the this operator is invoked? In the class 'Test' in the code below, the typecast operator...
3
by: A | last post by:
Hi, I understand that operator loading is used to support user-defined types. One of the requirements is that one of the arguments in an operator overloaded function must be of a user defined...
4
by: August1 | last post by:
I've written an interface and implementation file along with a client source file that allows the use of an overloaded subtraction operator. However, when using the program, I'm running into a...
20
by: Ioannis Vranos | last post by:
When we use the standard placement new operator provided in <new>, and not a definition of owr own, isn't a call to placement delete enough? Consider the code: #include <new>
2
by: wongjoekmeu | last post by:
Hello All, I have a question about a C++ listing that I don't understand from a book that I use to learn C++. In the listing a class String is declared and defined. The beginning look like this...
5
by: raylopez99 | last post by:
I need an example of a managed overloaded assignment operator for a reference class, so I can equate two classes A1 and A2, say called ARefClass, in this manner: A1=A2;. For some strange reason...
2
by: subramanian100in | last post by:
overloaded operator=() -------------------------------- overloaded assignment operator should be a non-static MEMBER function of a class. This ensures that the first operand is an lvalue. If...
9
by: itdevries | last post by:
Hi, I've ran into some trouble with an overloaded + operator, maybe someone can give me some hints what to look out for. I've got my own custom vector class, as a part of that I've overloaded...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
0
muto222
php
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.