C# et les propriétés
With VBScript and VB6, I can have arguments with the Property Get statement, like that :
Private Property Get OneData(ByVal sOneKey As String) As String
If (sOneKey = "dummy") Then
OneData = "qwerty"
Else
OneData = colDatas.item(sOneKey)
End If
End Property
Private Property Let OneData(ByVal sOneKey As String, ByVal sOneValue As String)
If (sOneKey <> "dummy") Then
colDatas.Add sOneKey, sOneValue
End If
End Property
With VB.NET, I can write that :
Public Property OneData(ByVal sOneKey As String) As String
Get
If (sOneKey = "dummy") Then
OneData = "qwerty"
Else
OneData = colDatas.Item(sOneKey)
End If
End Get
Set(ByVal Value As String)
If (sOneKey <> "dummy") Then
colDatas.Add(sOneKey, Value)
End If
End Set
End Property
But with c#, I don't know how to do that, since VS.NET doesn't accept this code :
public string OneData (string sOneKey) {
get {
if (sOneKey != "dummy") {
return _OneData.Values(sOneKey);
} else {
return "qwerty";
}
}
set {
if (sOneKey != "dummy")
_OneData.Add(sOneKey, value);
}
}
Some hints ?