473,322 Members | 1,473 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,322 software developers and data experts.

Operators do not work in VB.NET with a C# referenced assembly

Unfortunately due to project constraints I have to code in VB.NET of
which I have little experience with. I have a C# assembly referenced
which contains an object where the + and - operators have been
successfully overridden and in my other C# projects the following code
(changed for posting) compiles and works:

Field TheField = this.GetField(1);
TheField += this.GetField(2);
Etc...

When I attempt to do something similar in VB.NET I get the following
compiler error "Operator '+' is not defined for types 'Field' and
'Field'"
I've tried different variations of the code with no joy - can
anyone assist and tell me what I am doing wrong?

Dim TheField As Field = Me.GetField(1)
TheField += Me.GetField(2)
TheField = (TheField + me.GetField(3))

Thanks in advance

Mar 30 '06 #1
3 1152
VB.NET (at least in 1.1, not sure about 2.0) doesn't support operator
overloading.

So, to use it, you would have to call the methods that are generated that
represent the operators. If you use intellisense, you should be able to
find them. There is a naming convention for them (which unfortunately I
don't remember), but it would have the operator name in it. But in the end,
you would have to call a method, you wouldn't be able to use the operators.

<mk*****@hotmail.com> wrote in message
news:11********************@e56g2000cwe.googlegrou ps.com...
Unfortunately due to project constraints I have to code in VB.NET of
which I have little experience with. I have a C# assembly referenced
which contains an object where the + and - operators have been
successfully overridden and in my other C# projects the following code
(changed for posting) compiles and works:

Field TheField = this.GetField(1);
TheField += this.GetField(2);
Etc...

When I attempt to do something similar in VB.NET I get the following
compiler error "Operator '+' is not defined for types 'Field' and
'Field'"
I've tried different variations of the code with no joy - can
anyone assist and tell me what I am doing wrong?

Dim TheField As Field = Me.GetField(1)
TheField += Me.GetField(2)
TheField = (TheField + me.GetField(3))

Thanks in advance

Mar 30 '06 #2
Actually behing the scene .NET creates a method named "opp_add" (if I
remember). In VB.NET 2003, you have to call explicitely this method (is this
what you are using, I believe VB 2005 does this for you automatically when
the operator is used).

--
Patrice

<mk*****@hotmail.com> a écrit dans le message de news:
11********************@e56g2000cwe.googlegroups.co m...
Unfortunately due to project constraints I have to code in VB.NET of
which I have little experience with. I have a C# assembly referenced
which contains an object where the + and - operators have been
successfully overridden and in my other C# projects the following code
(changed for posting) compiles and works:

Field TheField = this.GetField(1);
TheField += this.GetField(2);
Etc...

When I attempt to do something similar in VB.NET I get the following
compiler error "Operator '+' is not defined for types 'Field' and
'Field'"
I've tried different variations of the code with no joy - can
anyone assist and tell me what I am doing wrong?

Dim TheField As Field = Me.GetField(1)
TheField += Me.GetField(2)
TheField = (TheField + me.GetField(3))

Thanks in advance

Mar 30 '06 #3
The generated method is called op_Addition.

In 2003 you must use this method:
Field1 = Field.op_Addition(Field2, Field3)

In 2005 you can use + just as in C#.:
Field1 = Field2 + Field3
/claes
"Patrice" <a@bc.c> wrote in message
news:uP**************@tk2msftngp13.phx.gbl...
Actually behing the scene .NET creates a method named "opp_add" (if I
remember). In VB.NET 2003, you have to call explicitely this method (is
this what you are using, I believe VB 2005 does this for you automatically
when the operator is used).

--
Patrice

<mk*****@hotmail.com> a écrit dans le message de news:
11********************@e56g2000cwe.googlegroups.co m...
Unfortunately due to project constraints I have to code in VB.NET of
which I have little experience with. I have a C# assembly referenced
which contains an object where the + and - operators have been
successfully overridden and in my other C# projects the following code
(changed for posting) compiles and works:

Field TheField = this.GetField(1);
TheField += this.GetField(2);
Etc...

When I attempt to do something similar in VB.NET I get the following
compiler error "Operator '+' is not defined for types 'Field' and
'Field'"
I've tried different variations of the code with no joy - can
anyone assist and tell me what I am doing wrong?

Dim TheField As Field = Me.GetField(1)
TheField += Me.GetField(2)
TheField = (TheField + me.GetField(3))

Thanks in advance


Mar 30 '06 #4

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

Similar topics

1
by: Jean Stax | last post by:
Hi ! I created a sample library project. In my second project I reference this library and make the following call, which returns "undefined value": Type myType =...
5
by: craig | last post by:
Is it possible to step into the code of a referenced .net assembly from within a project that is being debugged? Thanks!!!
3
by: Jimi | last post by:
What do I need to do to get details of an assembly that is not referenced by an app? I don't even know the classes contained in the assembly. If the assembly is referenced and I know the...
4
by: Jimi | last post by:
Given a C# project file path, can I use reflection to get all the assemblies referenced by the project? e.g., I know the path of a C# project, say, "c:\SomeProject.csproj", and I want to load...
1
by: Jimi | last post by:
(Sorry for the repost, but I thought maybe I'd have better luck this time) I'm working on a utility to provide an overview of one's .NET projects and one of the things I want to display is...
0
by: Michel Gallant | last post by:
I have a simple asp.net page, NET 1.1, and no web.config file. I place the main assembly source in following directory: C:\Inetpub\wwwroot\cryptonet I link in a referenced COM interop assembly...
48
by: spibou | last post by:
This concerns the Wikipedia article on C and C++ operators: http://en.wikipedia.org/wiki/Operators_in_C_and_C%2B%2B Until very recently the first table in the page was a very useful one on the...
3
by: Nick Gilbert | last post by:
Hi, In my VS.NET 2005, if I choose Build Clean Solution, the BIN folder is not touched. Shouldn't it delete all the dll and pdb files in that folder first? Instead, I'm finding I have to do it...
6
by: Jonas Huckestein | last post by:
hello, somehow i can't figure out, how to overload the operator for a referenced object. if i have class MyClass { int operator(int i) { return 1; }; };
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

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.