473,763 Members | 7,611 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 1748
No and no. VB does not support this.

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

"bi********@csa .com" <an*******@disc ussions.microso ft.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*******@disc ussions.microso ft.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********@emai l.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.c om> wrote in message
news:MP******** *************** *@news.newsguy. com...
In article <e0************ **@TK2MSFTNGP12 .phx.gbl>,
Ja********@emai l.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********@emai l.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.c om> wrote in message
news:MP******** *************** *@news.newsguy. com...
In article <u4************ **@TK2MSFTNGP10 .phx.gbl>,
Ja********@emai l.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********@emai l.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 "immediatel y 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.c om> wrote in message
news:MP******** *************** *@news.newsguy. com... In article <#G************ **@TK2MSFTNGP10 .phx.gbl>,
Ja********@emai l.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********@ema il.msn.com> wrote in message
news:Op******** *****@TK2MSFTNG P11.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 "immediatel y 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.c om> wrote in message
news:MP******** *************** *@news.newsguy. com...
In article <#G************ **@TK2MSFTNGP10 .phx.gbl>,
Ja********@emai l.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

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

Similar topics

4
2471
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 (English, French) in a *single* repository (<- files or database) and generate documents in the various languages and target formats (XHTML, PDF, HTML Help, Text) on demand. I am not a programmer, though, and can't develop my own tools, but of course...
2
11146
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 Project: * - System Architect * - Solution Architect * - Application Architect - Is this the same as a Solution Architect? * - Technical Architect
2
3855
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) cross platform across X and win32 4) free/cheap 5) minimalistic I've used wxWindows for non-technical programs and thought it was pretty good, but the built in plot widget (wxPlotWindow) sucks. Qt
5
3492
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 good tech support?? Thanks in advance for any input. Shaun
56
4339
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 C. wat type of questions should be expected? Which part of C language do the staff give more concern? The interviewers have just mentioned that .. i will have interview on C. Also can anyone can help me with sites where i can go thru sample
11
2185
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, can I ask again what effective escaping really means? Are the standard escaping functions found in the PHP, Tcl etc APIs to Postgres bombproof? Are there any encodings that might slip through and be cast to malicious strings inside Postgres?...
22
2624
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 education, bad police and a lot of taxes and bills to pay, and yes I live in a democratic "state" (corrupt, but democratic). So please, don't try to convince me about the social / economical / open source / give to all / be open / all people are...
0
9387
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10002
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
9938
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
1
7368
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6643
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5270
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5406
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
3528
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2794
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.