Re: public DataValue this[int column] indexing with int ???

Tech-Archive recommends: Repair Windows Errors & Optimize Windows Performance



John Liu wrote:
Some history, perhaps. I think the history of this goes back to VB6
(and may be other languages)

VBA more than VB.

> , there was this incredibly frustrating
idea called the default property. It got murdered in VB.NET (and there
was much rejoicing!)

No it didn't:

Public Class Foo

Private BarStuff As Integer() = New Integer(10) {}
Default Public Property Bar(ByVal i As Integer) As Integer
Get
Return BarStuff(i)
End Get
Set(ByVal value As Integer)
BarStuff(i) = value
End Set
End Property
End Class

And look, in VB.NET you can have default properties indexes by more than one parameter! Can't do that with a C# indexer:

Public Class Fooz

Private BarStuff As Integer(,) = New Integer(10, 20) {}
Default Public Property Bar(ByVal i As Integer, ByVal j As Integer) As Integer
Get
Return BarStuff(i, j)
End Get
Set(ByVal value As Integer)
BarStuff(i, j) = value
End Set
End Property
End Class

Usage:

Sub Main()

Dim f As New Foo, z As New Fooz

f(3) = 5

z(4, 5) = 6
End Sub


This concludes the cross-cultural lesson for today.

--
Larry Lard
larrylard@xxxxxxxxxxxxxx
The address is real, but unread - please reply to the group
For VB and C# questions - tell us which version
.



Relevant Pages

  • Re: ByRef/Ref passing in Web Services
    ... I swear I wrote an example last night which didn't, ... > public int xoxo; ... > public class WebService: System.Web.Services.WebService ...
    (microsoft.public.dotnet.framework)
  • Re: The curse of constant fields
    ... run, you need to recompile. ... public class Foo { ... so a dependency tree is needed after all. ...
    (comp.lang.java.programmer)
  • Re: Class Dispose
    ... public class Foo: IDisposable ... public void Dispose() ...
    (microsoft.public.dotnet.languages.csharp)
  • not possible to get propertyinfo for inherited private members?
    ... End Sub ... Public Class foo ... Public Property testpublicAs String ...
    (microsoft.public.dotnet.languages.vb)
  • Re: How to get the runtime class?
    ... > abstract public class foo { ... > the runtime class is type foo2 ... an object that is of class "foo2" you have some other problem. ... > public class foo2 extends foo { ...
    (comp.lang.java.programmer)