Accessors with parameters in C#

Iceplug

Well-known member
Joined
Aug 20, 2001
Messages
706
Location
South Carolina, USA
OK, Ive looked through my documentation and searched... and havent 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, youre out of luck. But, if you just need one, youre 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 Id have to make a class for each one of these parameters that I want for arrays.
Thanks! :)
 
Back
Top