Can I create a class in VB.NET which can be used from C# like that:
myObject.Objects[index].Prop = 1234;
Sure I could create a property which returns an array. But the requirement is that the index is 1-based, not 0-based, so this method has to map the indices somehow:
I was trying to make it like that, but C# told me I cannot call this directly:
Public ReadOnly Property Objects(ByVal index As Integer) As ObjectData
Get
If (index = 0) Then
Throw New ArgumentOutOfRangeException()
End If
Return parrObjectData(index)
End Get
End Property
EDIT Sorry if I was a bit unclear:
C# only allows my to call this method like
myObject.get_Objects(index).Prop = 1234
but not
myObject.Objects[index].Prop = 1234;
this is what I want to achieve.
Default
is the keyword that you're missing. Brian's answer has got you covered. – Riddell