João,
Stafano was close:
Default Public Property Myprop(ByVal index As Integer) As String
Get
If index >= 0 AndAlso index <= size - 1 Then
Return words(index)
Else
Return ""
End If
End Get
Set(ByVal value As String)
If index >= 0 AndAlso index <= size - 1 Then
words(index) = value
End If
End Set
End Property
The "Default" on the property makes it behave more like the indexer. An int
in C# is an Integer in VB.NET, in that they both are aliases to
System.Int32.
I don't see that the tmp in the getter is really doing anything (adding
value), so I removed it.
I would consider throwing an IndexOutOfRangeException or
ArgumentOutOfRangeException in the getter & setter...
Hope this helps
Jay
"João Santa Bárbara" <jo****@i24portugal.com> wrote in message
news:en**************@tk2msftngp13.phx.gbl...
hi all
how can i change this from C# to VB.NET
thsk
JSB
17: public string this[int index]
18: {
19: get
20: {
21: string tmp;
22:
23: if( index >= 0 && index <= size-1 )
24: tmp = words[index];
25: else
26: tmp = "";
27:
28: return ( tmp );
29: }
30: set
31: {
32: if( index >= 0 && index <= size-1 )
33: words[index] = value;
34: }
35: }