473,386 Members | 1,602 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,386 software developers and data experts.

Technical Question

Is it possible to overload operators in vb.net?

Is it possible to do programmer defined boxing on byvalue
variables in vb.net?
Jul 21 '05 #1
11 1712
No and no. VB does not support this.

If you need this capability, I recommend you use C#.

"bi********@csa.com" <an*******@discussions.microsoft.com> wrote in message
news:03****************************@phx.gbl...
Is it possible to overload operators in vb.net?

Is it possible to do programmer defined boxing on byvalue
variables in vb.net?

Jul 21 '05 #2
Bill,
You will need to wait for VB.NET 2004 (Whidbey) to get overloaded operators.

http://msdn.microsoft.com/vstudio/pr...o/roadmap.aspx

Hope this helps
Jay

"bi********@csa.com" <an*******@discussions.microsoft.com> wrote in message
news:03****************************@phx.gbl...
Is it possible to overload operators in vb.net?

Is it possible to do programmer defined boxing on byvalue
variables in vb.net?

Jul 21 '05 #3
In article <e0**************@TK2MSFTNGP12.phx.gbl>,
Ja********@email.msn.com says...
Bill,
You will need to wait for VB.NET 2004 (Whidbey) to get overloaded operators.


Will we then be able to overload the assignment operator in C#?

-- Rick

Jul 21 '05 #4
Rick,
Why would you want to?

With overloading implicit & explicit operators why would you want to
overload the assignment operator?

As for if C# is going to or not going to support overloading the assignment
operator, all I can say is what is in the article I referenced in my earlier
post.

Just a thought
Jay

"Guinness Mann" <GM***@dublin.com> wrote in message
news:MP************************@news.newsguy.com.. .
In article <e0**************@TK2MSFTNGP12.phx.gbl>,
Ja********@email.msn.com says...
Bill,
You will need to wait for VB.NET 2004 (Whidbey) to get overloaded
operators.
Will we then be able to overload the assignment operator in C#?

-- Rick

Jul 21 '05 #5
In article <u4**************@TK2MSFTNGP10.phx.gbl>,
Ja********@email.msn.com says...
With overloading implicit & explicit operators why would you want to
overload the assignment operator?


You're suggesting that:

MyStruct A = new MyStruct();
<some operations on A>
MyStruct B = new MyStruct(A);

Is better than:

MyStruct A = new MyStruct();
MyStruct B = new MyStruct();
<some operations on A>
B = A;

-- Rick
Jul 21 '05 #6
Rick,
No. My question is not suggesting anything, my question is asking a
question. I restated my first question "Why would you want to overload the
assignment operator?", Maybe I inverted the second question, and I should
have asked "What would you do with an overloaded assignment operator that
you cannot do with implicit & explicit operators?"

Again these are questions, not suggestions. If you answer the questions,
then maybe I or someone else can give you a plausible answer.

I am not seeing, as you did not demonstrate, in your example how overloading
the assignment operator will help, Care to explain what you are thinking,
what you are after in your example.

Remember I am not suggesting anything, I am asking you a question on what
you are wanting in an overloaded assignment operator!

Thanks for understanding.

Jay

"Guinness Mann" <GM***@dublin.com> wrote in message
news:MP************************@news.newsguy.com.. .
In article <u4**************@TK2MSFTNGP10.phx.gbl>,
Ja********@email.msn.com says...
With overloading implicit & explicit operators why would you want to
overload the assignment operator?


You're suggesting that:

MyStruct A = new MyStruct();
<some operations on A>
MyStruct B = new MyStruct(A);

Is better than:

MyStruct A = new MyStruct();
MyStruct B = new MyStruct();
<some operations on A>
B = A;

-- Rick

Jul 21 '05 #7
In article <#G**************@TK2MSFTNGP10.phx.gbl>,
Ja********@email.msn.com says...
Remember I am not suggesting anything, I am asking you a question on what
you are wanting in an overloaded assignment operator!


So that I can do this:
MyStruct A = new MyStruct();
MyStruct B = new MyStruct();
<some operations on A>
B = A;


In a practical application, there would be operations on B, also. You
want a concrete example? Suppose that A and B represent the tuning
registers on two radios and that occasionally I want to synchronize
them.

-- Rick
Jul 21 '05 #8
Rick,
want a concrete example? Suppose that A and B represent the tuning
registers on two radios and that occasionally I want to synchronize
them. It would seem that you want to redefine the meaning of what assignment is to
be mean synchronize.

Where assignment means to replace one object with another, and synchronize
means to update part of one object with parts of another object.

Reading your initial example I took it to be assignment, as that is what you
had, now you are telling me you really meant for it to be synchronize.

How is any one other than you, to know that although you are using the
assignment operator you really intend for the synchronize "operation" to be
performed?

Further, if "=" is now synchronize, how do you propose to assign one
MyStruct variable to a different MyStruct variable?

Lastly using the assignment operator to mean synchronize also goes against
the .NET Design Guidelines for Class Library Developers.

<blockquote>
Use operator overloading in cases where it is immediately obvious what the
result of the operation will be. For example it makes sense to be able to
subtract one Time value from another Time value and get a TimeSpan. However,
it is not appropriate to use the or operator to create the union of two
database queries, or to use shift to write to a stream.
</blockquote>

http://msdn.microsoft.com/library/de...Guidelines.asp

Notice the "immediately obvious" in that statement.

Personally if I wanted two objects to be synchronized I would have one
object raise events that the other object listened to updating itself
accordingly. Or the class would have a Synchronize or UpdateWith method.
MyStruct A = new MyStruct();
MyStruct B = new MyStruct();
<some operations on A>
B.Synchronize(A);

Hope this helps
Jay

"Guinness Mann" <GM***@dublin.com> wrote in message
news:MP************************@news.newsguy.com.. . In article <#G**************@TK2MSFTNGP10.phx.gbl>,
Ja********@email.msn.com says...
Remember I am not suggesting anything, I am asking you a question on what you are wanting in an overloaded assignment operator!


So that I can do this:
MyStruct A = new MyStruct();
MyStruct B = new MyStruct();
<some operations on A>
B = A;


In a practical application, there would be operations on B, also. You
want a concrete example? Suppose that A and B represent the tuning
registers on two radios and that occasionally I want to synchronize
them.

-- Rick

Jul 21 '05 #9
Doh!
Where assignment means to replace one object with another, and synchronize
means to update part of one object with parts of another object. Technically I should have stated, "replace one variable with another
variable".

Jay

"Jay B. Harlow [MVP - Outlook]" <Ja********@email.msn.com> wrote in message
news:Op*************@TK2MSFTNGP11.phx.gbl... Rick,
want a concrete example? Suppose that A and B represent the tuning
registers on two radios and that occasionally I want to synchronize
them. It would seem that you want to redefine the meaning of what assignment is

to be mean synchronize.

Where assignment means to replace one object with another, and synchronize
means to update part of one object with parts of another object.

Reading your initial example I took it to be assignment, as that is what you had, now you are telling me you really meant for it to be synchronize.

How is any one other than you, to know that although you are using the
assignment operator you really intend for the synchronize "operation" to be performed?

Further, if "=" is now synchronize, how do you propose to assign one
MyStruct variable to a different MyStruct variable?

Lastly using the assignment operator to mean synchronize also goes against
the .NET Design Guidelines for Class Library Developers.

<blockquote>
Use operator overloading in cases where it is immediately obvious what the
result of the operation will be. For example it makes sense to be able to
subtract one Time value from another Time value and get a TimeSpan. However, it is not appropriate to use the or operator to create the union of two
database queries, or to use shift to write to a stream.
</blockquote>

http://msdn.microsoft.com/library/de...Guidelines.asp
Notice the "immediately obvious" in that statement.

Personally if I wanted two objects to be synchronized I would have one
object raise events that the other object listened to updating itself
accordingly. Or the class would have a Synchronize or UpdateWith method.
> MyStruct A = new MyStruct();
> MyStruct B = new MyStruct();
> <some operations on A>
> B.Synchronize(A);
Hope this helps
Jay

"Guinness Mann" <GM***@dublin.com> wrote in message
news:MP************************@news.newsguy.com.. .
In article <#G**************@TK2MSFTNGP10.phx.gbl>,
Ja********@email.msn.com says...
Remember I am not suggesting anything, I am asking you a question on

what you are wanting in an overloaded assignment operator!


So that I can do this:
> MyStruct A = new MyStruct();
> MyStruct B = new MyStruct();
> <some operations on A>
> B = A;


In a practical application, there would be operations on B, also. You
want a concrete example? Suppose that A and B represent the tuning
registers on two radios and that occasionally I want to synchronize
them.

-- Rick


Jul 21 '05 #10
In article <Op*************@TK2MSFTNGP11.phx.gbl>,
Ja********@email.msn.com says...

Does that mean no?

-- Rick

P.S. Do you have any examples of how to parse Word XP files using XML?
Does Office 2003 have better support for such an operation?
[RF]

Rick,
want a concrete example? Suppose that A and B represent the tuning
registers on two radios and that occasionally I want to synchronize
them.

It would seem that you want to redefine the meaning of what assignment is to
be mean synchronize.

Where assignment means to replace one object with another, and synchronize
means to update part of one object with parts of another object.

Reading your initial example I took it to be assignment, as that is what you
had, now you are telling me you really meant for it to be synchronize.

How is any one other than you, to know that although you are using the
assignment operator you really intend for the synchronize "operation" to be
performed?

Further, if "=" is now synchronize, how do you propose to assign one
MyStruct variable to a different MyStruct variable?

Lastly using the assignment operator to mean synchronize also goes against
the .NET Design Guidelines for Class Library Developers.

<blockquote>
Use operator overloading in cases where it is immediately obvious what the
result of the operation will be. For example it makes sense to be able to
subtract one Time value from another Time value and get a TimeSpan. However,
it is not appropriate to use the or operator to create the union of two
database queries, or to use shift to write to a stream.
</blockquote>

http://msdn.microsoft.com/library/de...Guidelines.asp

Notice the "immediately obvious" in that statement.

Personally if I wanted two objects to be synchronized I would have one
object raise events that the other object listened to updating itself
accordingly. Or the class would have a Synchronize or UpdateWith method.
> MyStruct A = new MyStruct();
> MyStruct B = new MyStruct();
> <some operations on A>
> B.Synchronize(A);


Hope this helps
Jay

"Guinness Mann" <GM***@dublin.com> wrote in message
news:MP************************@news.newsguy.com.. .
In article <#G**************@TK2MSFTNGP10.phx.gbl>,

Jul 21 '05 #11
Rick,
I believe we had earlier established that current versions of C# do not
support overloading the assignment operator. That all I know about future
versions of C# or VB.NET is what is documented in the roadmap.

http://msdn.microsoft.com/vstudio/pr...o/roadmap.aspx

That the road map does not confirm nor deny that overloading the assignment
operator will be supported in the next or future versions of either C# or
VB.NET.

Hope this helps
Jay

"Guinness Mann" <GM***@dublin.com> wrote in message
news:MP************************@news.newsguy.com.. .
In article <Op*************@TK2MSFTNGP11.phx.gbl>,
Ja********@email.msn.com says...

Does that mean no?

-- Rick

P.S. Do you have any examples of how to parse Word XP files using XML?
Does Office 2003 have better support for such an operation?
[RF]

Rick,
want a concrete example? Suppose that A and B represent the tuning
registers on two radios and that occasionally I want to synchronize
them.

It would seem that you want to redefine the meaning of what assignment is to be mean synchronize.

Where assignment means to replace one object with another, and synchronize means to update part of one object with parts of another object.

Reading your initial example I took it to be assignment, as that is what you had, now you are telling me you really meant for it to be synchronize.

How is any one other than you, to know that although you are using the
assignment operator you really intend for the synchronize "operation" to be performed?

Further, if "=" is now synchronize, how do you propose to assign one
MyStruct variable to a different MyStruct variable?

Lastly using the assignment operator to mean synchronize also goes against the .NET Design Guidelines for Class Library Developers.

<blockquote>
Use operator overloading in cases where it is immediately obvious what the result of the operation will be. For example it makes sense to be able to subtract one Time value from another Time value and get a TimeSpan. However, it is not appropriate to use the or operator to create the union of two
database queries, or to use shift to write to a stream.
</blockquote>

http://msdn.microsoft.com/library/de...Guidelines.asp
Notice the "immediately obvious" in that statement.

Personally if I wanted two objects to be synchronized I would have one
object raise events that the other object listened to updating itself
accordingly. Or the class would have a Synchronize or UpdateWith method.
> > MyStruct A = new MyStruct();
> > MyStruct B = new MyStruct();
> > <some operations on A>
> > B.Synchronize(A);


Hope this helps
Jay

"Guinness Mann" <GM***@dublin.com> wrote in message
news:MP************************@news.newsguy.com.. .
In article <#G**************@TK2MSFTNGP10.phx.gbl>,

Jul 21 '05 #12

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

Similar topics

4
by: David Winter | last post by:
As a technical author and translator, I am highly interested in single source/multi format publishing. Meaning: I'd like to keep manuals, technical specifications etc. in multiple languages...
2
by: Vick | last post by:
Hi Folks, I'm not too sure if this is the appropriate place to ask this question, but I'm trying to figure out what some of the main differences between the following Job roles are on an IT...
2
by: Junpei | last post by:
I need recommendations for a scientific app I'm making, here's what i need, in order of importance 1) Strong/Complete 2d/3d plotting widgets for both data and functions 2) Realtime 2d-plotting 3)...
5
by: shaun.mostashari | last post by:
Hello all, I am working on a trade study and one of the criterias is how easy it is to get DB2 technical support from IBM. I appreciate if you guys share your experience with me. Does DB2 have a...
56
by: Cherrish Vaidiyan | last post by:
Frinds, Hope everyone is doing fine.i feel pointers to be the most toughest part in C. i have just completed learning pointers & arrays related portions. I need to attend technical interview on...
11
by: Geoff Caplan | last post by:
Hi folks, The thread on injection attacks was very instructive, but seemed to run out of steam at an interesting point. Now you guys have kindly educated me about the real nature of the issues,...
22
by: flit | last post by:
Hello All, I have a hard question, every time I look for this answer its get out from the technical domain and goes on in the moral/social domain. First, I live in third world with bad gov., bad...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
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
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...

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.