Accessors with parameters in C#

Iceplug

Contributor
Joined
Aug 20, 2001
Messages
709
Location
California, USA
OK, I've looked through my documentation and searched... and haven't found anything like this:
In VB, you can make property procedures with parameters:
Public Property TileData(ByVal Col As Integer, ByVal Row As Integer) As Short
Get
Return mTiles(Col, Row).Data
End Get
Set(ByVal Value As Short)
mTiles(Col, Row).Data = Value
End Set
End Property

Is the same possible in C# or something similar?
When I try using it, I get errors-a-plenty. :)
 
True - but only as the default property for a class, so if you need more than one indexed property in this class, you're out of luck. But, if you just need one, you're good to go.

I also went through this unfortunate discovery a while back, only to find another perk that vb.net gives you.
 
Hmm... I was afraid of that. :(
(But I did learn about indexers yay!) :)
I guess that means that I'd have to make a class for each one of these parameters that I want for arrays.
Thanks! :)
 
Back
Top