I found the following syntax as a VB.NET property and I’m trying to convert it to c#, but I’m not sure how to accomplish that.
Public Property SomeText(ByVal someEnumThing as SomeEnum) As String
Get
Select Case someEnumThing
//figure out what string to return
End Select
End Get
Set(ByVal Value as String)
Select Case someEnumThing
//figure out what string to set
End Select
End Set
End Property
I’ve never seen a property done like this before, any ideas?
I guess you’re referring to the arguments for the property. Well, as far as I know, C# only supports them for indexers, which cannot have a name (e.g.
this[SomeEnum someEnumThing] {}).If you want to get a similar behavior, you can create a helper class with an indexer property and use it to expose the “name” of the property: