hi all.
can i OverLoad Operators - such as Exclamation Mark "!" ?
how? 10 2187
You cant in VB.NET
--
OHM ( Terry Burns )
. . . One-Handed-Man . . .
If U Need My Email ,Ask Me
Time flies when you don't know what you're doing
"shachar" <an*******@discussions.microsoft.com> wrote in message
news:36****************************@phx.gbl... hi all. can i OverLoad Operators - such as Exclamation Mark "!" ? how?
And by the way. You can overload operators in VS2005, however, the !
operator is not currently overloadable as per Beta1
--
OHM ( Terry Burns )
. . . One-Handed-Man . . .
If U Need My Email ,Ask Me
Time flies when you don't know what you're doing
"One Handed Man ( OHM - Terry Burns )" <news.microsoft.com> wrote in message
news:ue**************@TK2MSFTNGP09.phx.gbl... You cant in VB.NET
--
OHM ( Terry Burns ) . . . One-Handed-Man . . . If U Need My Email ,Ask Me
Time flies when you don't know what you're doing
"shachar" <an*******@discussions.microsoft.com> wrote in message news:36****************************@phx.gbl... hi all. can i OverLoad Operators - such as Exclamation Mark "!" ? how?
Visual Basic .NET 2002 & 2003 do not support operator overloading, but the
upcoming 2005 version.
"shachar" <an*******@discussions.microsoft.com> wrote in message
news:36****************************@phx.gbl...
hi all.
can i OverLoad Operators - such as Exclamation Mark "!" ?
how?
Yes, but 2005 ( VB.NET ) does not overload the ! operator unfortunately.
HTH
--
OHM ( Terry Burns )
. . . One-Handed-Man . . .
If U Need My Email ,Ask Me
Time flies when you don't know what you're doing
"Shiva" <sh******@online.excite.com> wrote in message
news:%2****************@TK2MSFTNGP11.phx.gbl... Visual Basic .NET 2002 & 2003 do not support operator overloading, but the upcoming 2005 version.
"shachar" <an*******@discussions.microsoft.com> wrote in message news:36****************************@phx.gbl... hi all. can i OverLoad Operators - such as Exclamation Mark "!" ? how?
Shachar,
The Exclamation Mark "!" operator is short hand for the default property
that accepts only a string. http://msdn.microsoft.com/library/de...bspec9_4_1.asp
To overload it (in both VB.NET 2002 & VB.NET 2003), you simply add a Default
Property Item(key As String) to your class, something like:
Public Class MyDictionary
Inherits DictionaryBase
Default Public ReadOnly Property Item(ByVal name As String) As
MyObject
Get
Return DirectCast(Me.InnerHashtable.Item(name), MyObject)
End Get
End Property
End Class
Dim value As MyObject
Dim dictionary As MyDictionary
value = dictionary!SomeKey
As OHM suggests for other operators you need to wait for VS.NET 2005 (aka
Whidbey, due out later in 2005).
Hope this helps
Jay
"shachar" <an*******@discussions.microsoft.com> wrote in message
news:36****************************@phx.gbl... hi all. can i OverLoad Operators - such as Exclamation Mark "!" ? how?
Thats odd, I must admit I didnt look into it to closely, except that I tried
to overload it in 2005 and it told me that this operator is not
overloadable.
Oh Well, another item learned.
--
OHM ( Terry Burns )
. . . One-Handed-Man . . .
If U Need My Email ,Ask Me
Time flies when you don't know what you're doing
"Jay B. Harlow [MVP - Outlook]" <Ja************@msn.com> wrote in message
news:uP**************@TK2MSFTNGP14.phx.gbl... Shachar, The Exclamation Mark "!" operator is short hand for the default property that accepts only a string.
http://msdn.microsoft.com/library/de...bspec9_4_1.asp To overload it (in both VB.NET 2002 & VB.NET 2003), you simply add a
Default Property Item(key As String) to your class, something like:
Public Class MyDictionary Inherits DictionaryBase
Default Public ReadOnly Property Item(ByVal name As String) As MyObject Get Return DirectCast(Me.InnerHashtable.Item(name), MyObject) End Get End Property
End Class
Dim value As MyObject Dim dictionary As MyDictionary
value = dictionary!SomeKey
As OHM suggests for other operators you need to wait for VS.NET 2005 (aka Whidbey, due out later in 2005).
Hope this helps Jay
"shachar" <an*******@discussions.microsoft.com> wrote in message news:36****************************@phx.gbl... hi all. can i OverLoad Operators - such as Exclamation Mark "!" ? how?
OHM,
Unfortunately the term "overload" is overloaded here ;-)
You are correct, you don't actually Overload the "!" Operator per se, as my
sample shows you actually implement a specific method, that the "!" operator
then makes use of.
If the OP actually wanted to overload the "!" operator to give it meaning
other then "dictionary member access" (which is frowned upon anyway) you
cannot do that. However I'm not sure what meaning you would give "!" as its
use is very syntax specific.
As you may know the following three lines are identical, given "Dim x As
HashTable":
y = x!abc
y = x("abc")
y = x.Item("abc")
Hope this helps
Jay
"One Handed Man ( OHM - Terry Burns )" <news.microsoft.com> wrote in message
news:O1*************@TK2MSFTNGP12.phx.gbl... Thats odd, I must admit I didnt look into it to closely, except that I tried to overload it in 2005 and it told me that this operator is not overloadable.
Oh Well, another item learned.
--
OHM ( Terry Burns ) . . . One-Handed-Man . . . If U Need My Email ,Ask Me
Time flies when you don't know what you're doing
"Jay B. Harlow [MVP - Outlook]" <Ja************@msn.com> wrote in message news:uP**************@TK2MSFTNGP14.phx.gbl... Shachar, The Exclamation Mark "!" operator is short hand for the default property that accepts only a string.
http://msdn.microsoft.com/library/de...bspec9_4_1.asp To overload it (in both VB.NET 2002 & VB.NET 2003), you simply add a
Default Property Item(key As String) to your class, something like:
Public Class MyDictionary Inherits DictionaryBase
Default Public ReadOnly Property Item(ByVal name As String) As MyObject Get Return DirectCast(Me.InnerHashtable.Item(name), MyObject) End Get End Property
End Class
Dim value As MyObject Dim dictionary As MyDictionary
value = dictionary!SomeKey
As OHM suggests for other operators you need to wait for VS.NET 2005 (aka Whidbey, due out later in 2005).
Hope this helps Jay
"shachar" <an*******@discussions.microsoft.com> wrote in message news:36****************************@phx.gbl... > hi all. > can i OverLoad Operators - such as Exclamation Mark "!" ? > how? >
I understand this, but its not a well known operator really.
Thanks for the tip Jay.
--
OHM ( Terry Burns )
. . . One-Handed-Man . . .
If U Need My Email ,Ask Me
Time flies when you don't know what you're doing
"Jay B. Harlow [MVP - Outlook]" <Ja************@msn.com> wrote in message
news:%2****************@TK2MSFTNGP09.phx.gbl... OHM, Unfortunately the term "overload" is overloaded here ;-)
You are correct, you don't actually Overload the "!" Operator per se, as
my sample shows you actually implement a specific method, that the "!"
operator then makes use of.
If the OP actually wanted to overload the "!" operator to give it meaning other then "dictionary member access" (which is frowned upon anyway) you cannot do that. However I'm not sure what meaning you would give "!" as
its use is very syntax specific.
As you may know the following three lines are identical, given "Dim x As HashTable":
y = x!abc y = x("abc") y = x.Item("abc")
Hope this helps Jay
"One Handed Man ( OHM - Terry Burns )" <news.microsoft.com> wrote in
message news:O1*************@TK2MSFTNGP12.phx.gbl... Thats odd, I must admit I didnt look into it to closely, except that I tried to overload it in 2005 and it told me that this operator is not overloadable.
Oh Well, another item learned.
--
OHM ( Terry Burns ) . . . One-Handed-Man . . . If U Need My Email ,Ask Me
Time flies when you don't know what you're doing
"Jay B. Harlow [MVP - Outlook]" <Ja************@msn.com> wrote in
message news:uP**************@TK2MSFTNGP14.phx.gbl... Shachar, The Exclamation Mark "!" operator is short hand for the default
property that accepts only a string.
http://msdn.microsoft.com/library/de...bspec9_4_1.asp To overload it (in both VB.NET 2002 & VB.NET 2003), you simply add a
Default Property Item(key As String) to your class, something like:
Public Class MyDictionary Inherits DictionaryBase
Default Public ReadOnly Property Item(ByVal name As String) As MyObject Get Return DirectCast(Me.InnerHashtable.Item(name),
MyObject) End Get End Property
End Class
Dim value As MyObject Dim dictionary As MyDictionary
value = dictionary!SomeKey
As OHM suggests for other operators you need to wait for VS.NET 2005
(aka Whidbey, due out later in 2005).
Hope this helps Jay
"shachar" <an*******@discussions.microsoft.com> wrote in message news:36****************************@phx.gbl... > hi all. > can i OverLoad Operators - such as Exclamation Mark "!" ? > how? >
OHM, but its not a well known operator really.
Not well known also not widely promoted. :-)
I've remember seeing one or two places that even discourage its use,
especially in VB6 & VBA (MS Access) (links not available).
I've never really seen it promoted in VB.NET, except where I refer to it. I
find it a handy short cut. Although I am inconsistent on its use...
Paul Vick's "The Visual Basic .NET Programming Language" from Addison Wesley
has a topic on it.
If you don't have it I would recommend Paul's book, as I find Paul's book to
be a good (right size, right content) desk reference to the VB.NET language
itself. Paul's book covers just the language, not the framework.
Hope this helps
Jay
"One Handed Man ( OHM - Terry Burns )" <news.microsoft.com> wrote in message
news:ut**************@tk2msftngp13.phx.gbl...I understand this, but its not a well known operator really.
Thanks for the tip Jay.
--
OHM ( Terry Burns ) . . . One-Handed-Man . . . If U Need My Email ,Ask Me
Time flies when you don't know what you're doing
<<snip>>
Thanks
--
OHM ( Terry Burns )
. . . One-Handed-Man . . .
If U Need My Email ,Ask Me
Time flies when you don't know what you're doing
"Jay B. Harlow [MVP - Outlook]" <Ja************@msn.com> wrote in message
news:eB**************@TK2MSFTNGP09.phx.gbl... OHM,but its not a well known operator really. Not well known also not widely promoted. :-)
I've remember seeing one or two places that even discourage its use, especially in VB6 & VBA (MS Access) (links not available).
I've never really seen it promoted in VB.NET, except where I refer to it.
I find it a handy short cut. Although I am inconsistent on its use...
Paul Vick's "The Visual Basic .NET Programming Language" from Addison
Wesley has a topic on it.
If you don't have it I would recommend Paul's book, as I find Paul's book
to be a good (right size, right content) desk reference to the VB.NET
language itself. Paul's book covers just the language, not the framework.
Hope this helps Jay
"One Handed Man ( OHM - Terry Burns )" <news.microsoft.com> wrote in
message news:ut**************@tk2msftngp13.phx.gbl...I understand this, but its not a well known operator really.
Thanks for the tip Jay.
--
OHM ( Terry Burns ) . . . One-Handed-Man . . . If U Need My Email ,Ask Me
Time flies when you don't know what you're doing
<<snip>>
This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: bsaucer |
last post by:
I am creating a class with operator overloads. It makes references to another
class I've created, but do not wish to modify. I try to overload an operator
having arguments having the other class...
|
by: Mario Charest |
last post by:
..
Hi,
It's possible to overload the operator, but I wonder if it's possible to
somehow overload and so forth.
My goal would be to switch from static array declaration into something...
|
by: Hunter Hou |
last post by:
Hi,
I have this program, compiling is passed, but when i wanted to get the
executable file(g++ -o output input.o), it fails.
Who can lead me where the error is?
Thanks,
Hunter
===
|
by: Tony Johansson |
last post by:
Hello!
I just wonder if it's possible to overload a method only by having a
different return type.
//Tony
|
by: Chris |
last post by:
To me, this seems rather redundant. The compiler requires that if you
overload the == operator, you must also overload the != operator. All I do
for the != operator is something like this:
...
|
by: needin4mation |
last post by:
The code is taken from the book Professional C#:
abstract class GenericCustomer
{
private string name;
public GenericCustomer(string name)
{
this.name = name;
}...
|
by: bhavin |
last post by:
it is possible to overload new and delete operator but why is it needed to overload new and delete this question is asked by my professor so please any body reply to this question,also explain in a...
|
by: richard.parker |
last post by:
Hello,
I need to overload operator new with affecting the system libraries.
Has anyone done this? I've got 2 static libraries and application
source code where the operator needs to be...
|
by: v4vijayakumar |
last post by:
When (at which phase of the software development) the decision would
usually be taken to overload operators? Will you first design with
functions and then move these functionalities to overloaded...
|
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,...
|
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$) {
}
...
|
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
|
by: BarryA |
last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
|
by: Sonnysonu |
last post by:
This is the data of csv file
1 2 3
1 2 3
1 2 3
1 2 3
2 3
2 3
3
the lengths should be different i have to store the data by column-wise with in the specific length.
suppose the i have to...
|
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,...
|
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...
|
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,...
|
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...
| |