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" <anonymous@disc ussions.microso ft.com> wrote in message
news:363c01c4a4 84$638586b0$a40 1280a@phx.gbl.. .[color=blue]
> hi all.
> can i OverLoad Operators - such as Exclamation Mark "!" ?
> how?
>[/color]
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:ueAoyzIpEH A.2068@TK2MSFTN GP09.phx.gbl...[color=blue]
> 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" <anonymous@disc ussions.microso ft.com> wrote in message
> news:363c01c4a4 84$638586b0$a40 1280a@phx.gbl.. .[color=green]
> > hi all.
> > can i OverLoad Operators - such as Exclamation Mark "!" ?
> > how?
> >[/color]
>
>[/color]
Visual Basic .NET 2002 & 2003 do not support operator overloading, but the
upcoming 2005 version.
"shachar" <anonymous@disc ussions.microso ft.com> wrote in message
news:363c01c4a4 84$638586b0$a40 1280a@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" <shiva_sm@onlin e.excite.com> wrote in message
news:%23CZUr6Ip EHA.3520@TK2MSF TNGP11.phx.gbl. ..[color=blue]
> Visual Basic .NET 2002 & 2003 do not support operator overloading, but the
> upcoming 2005 version.
>
> "shachar" <anonymous@disc ussions.microso ft.com> wrote in message
> news:363c01c4a4 84$638586b0$a40 1280a@phx.gbl.. .
> hi all.
> can i OverLoad Operators - such as Exclamation Mark "!" ?
> how?
>
>[/color]
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.I nnerHashtable.I tem(name), MyObject)
End Get
End Property
End Class
Dim value As MyObject
Dim dictionary As MyDictionary
value = dictionary!Some Key
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" <anonymous@disc ussions.microso ft.com> wrote in message
news:363c01c4a4 84$638586b0$a40 1280a@phx.gbl.. .[color=blue]
> hi all.
> can i OverLoad Operators - such as Exclamation Mark "!" ?
> how?
>[/color]
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]" <Jay_Harlow_MVP @msn.com> wrote in message
news:uPGNgNKpEH A.3592@TK2MSFTN GP14.phx.gbl...[color=blue]
> Shachar,
> The Exclamation Mark "!" operator is short hand for the default property
> that accepts only a string.
>
>[/color] http://msdn.microsoft.com/library/de...bspec9_4_1.asp[color=blue]
>
> To overload it (in both VB.NET 2002 & VB.NET 2003), you simply add a[/color]
Default[color=blue]
> 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.I nnerHashtable.I tem(name), MyObject)
> End Get
> End Property
>
> End Class
>
> Dim value As MyObject
> Dim dictionary As MyDictionary
>
> value = dictionary!Some Key
>
>
> 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" <anonymous@disc ussions.microso ft.com> wrote in message
> news:363c01c4a4 84$638586b0$a40 1280a@phx.gbl.. .[color=green]
> > hi all.
> > can i OverLoad Operators - such as Exclamation Mark "!" ?
> > how?
> >[/color]
>
>[/color]
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:O12QE3KpEH A.896@TK2MSFTNG P12.phx.gbl...[color=blue]
> 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]" <Jay_Harlow_MVP @msn.com> wrote in message
> news:uPGNgNKpEH A.3592@TK2MSFTN GP14.phx.gbl...[color=green]
>> Shachar,
>> The Exclamation Mark "!" operator is short hand for the default property
>> that accepts only a string.
>>
>>[/color]
> http://msdn.microsoft.com/library/de...bspec9_4_1.asp[color=green]
>>
>> To overload it (in both VB.NET 2002 & VB.NET 2003), you simply add a[/color]
> Default[color=green]
>> 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.I nnerHashtable.I tem(name), MyObject)
>> End Get
>> End Property
>>
>> End Class
>>
>> Dim value As MyObject
>> Dim dictionary As MyDictionary
>>
>> value = dictionary!Some Key
>>
>>
>> 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" <anonymous@disc ussions.microso ft.com> wrote in message
>> news:363c01c4a4 84$638586b0$a40 1280a@phx.gbl.. .[color=darkred]
>> > hi all.
>> > can i OverLoad Operators - such as Exclamation Mark "!" ?
>> > how?
>> >[/color]
>>
>>[/color]
>
>[/color]
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]" <Jay_Harlow_MVP @msn.com> wrote in message
news:%230PGxLLp EHA.1988@TK2MSF TNGP09.phx.gbl. ..[color=blue]
> OHM,
> Unfortunately the term "overload" is overloaded here ;-)
>
> You are correct, you don't actually Overload the "!" Operator per se, as[/color]
my[color=blue]
> sample shows you actually implement a specific method, that the "!"[/color]
operator[color=blue]
> 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[/color]
its[color=blue]
> 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[/color]
message[color=blue]
> news:O12QE3KpEH A.896@TK2MSFTNG P12.phx.gbl...[color=green]
> > 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]" <Jay_Harlow_MVP @msn.com> wrote in[/color][/color]
message[color=blue][color=green]
> > news:uPGNgNKpEH A.3592@TK2MSFTN GP14.phx.gbl...[color=darkred]
> >> Shachar,
> >> The Exclamation Mark "!" operator is short hand for the default[/color][/color][/color]
property[color=blue][color=green][color=darkred]
> >> that accepts only a string.
> >>
> >>[/color]
> >[/color][/color] http://msdn.microsoft.com/library/de...bspec9_4_1.asp[color=blue][color=green][color=darkred]
> >>
> >> To overload it (in both VB.NET 2002 & VB.NET 2003), you simply add a[/color]
> > Default[color=darkred]
> >> 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.I nnerHashtable.I tem(name),[/color][/color][/color]
MyObject)[color=blue][color=green][color=darkred]
> >> End Get
> >> End Property
> >>
> >> End Class
> >>
> >> Dim value As MyObject
> >> Dim dictionary As MyDictionary
> >>
> >> value = dictionary!Some Key
> >>
> >>
> >> As OHM suggests for other operators you need to wait for VS.NET 2005[/color][/color][/color]
(aka[color=blue][color=green][color=darkred]
> >> Whidbey, due out later in 2005).
> >>
> >> Hope this helps
> >> Jay
> >>
> >> "shachar" <anonymous@disc ussions.microso ft.com> wrote in message
> >> news:363c01c4a4 84$638586b0$a40 1280a@phx.gbl.. .
> >> > hi all.
> >> > can i OverLoad Operators - such as Exclamation Mark "!" ?
> >> > how?
> >> >
> >>
> >>[/color]
> >
> >[/color]
>
>[/color]
OHM,[color=blue]
>but its not a well known operator really.[/color]
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:utx9tDMpEH A.3848@tk2msftn gp13.phx.gbl...[color=blue]
>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
>[/color]
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]" <Jay_Harlow_MVP @msn.com> wrote in message
news:eBpksMMpEH A.3728@TK2MSFTN GP09.phx.gbl...[color=blue]
> OHM,[color=green]
> >but its not a well known operator really.[/color]
> 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.[/color]
I[color=blue]
> find it a handy short cut. Although I am inconsistent on its use...
>
> Paul Vick's "The Visual Basic .NET Programming Language" from Addison[/color]
Wesley[color=blue]
> has a topic on it.
>
> If you don't have it I would recommend Paul's book, as I find Paul's book[/color]
to[color=blue]
> be a good (right size, right content) desk reference to the VB.NET[/color]
language[color=blue]
> 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[/color]
message[color=blue]
> news:utx9tDMpEH A.3848@tk2msftn gp13.phx.gbl...[color=green]
> >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
> >[/color]
>
> <<snip>>
>
>[/color]
Comment