morleyhill
Programmer
Hi Everyone
I'm an experienced VB.Net programmer but just starting to pick up C#. I'm trying to convert some VB.Net clases into equivalent C# and I've hit a problem with converting a parametized property. Can someone please help me convert the following VB.Net into C#-
Default Public Property Item(ByVal index As Integer) As String
Get
Return List.Item(index).ToString
End Get
Set(ByVal Value As String)
List.Item(index) = Value
End Set
End Property
I've two problems-
1. What is the correct syntax for flagging the property as Default?
2. How do I implement the parameter 'index'?
I used an online VB.Net to C# conversion tool which produced the following-
public string Item
{
get
{
return List.Item(index).ToString;
}
set
{
List.Item(index) = value;
}
}
but the 'default' setting is lost and the compiler complains that 'index' isn't defined.
This is such a common and simple pattern I'm struggling to understand where I'm going wrong!!!
I'm an experienced VB.Net programmer but just starting to pick up C#. I'm trying to convert some VB.Net clases into equivalent C# and I've hit a problem with converting a parametized property. Can someone please help me convert the following VB.Net into C#-
Default Public Property Item(ByVal index As Integer) As String
Get
Return List.Item(index).ToString
End Get
Set(ByVal Value As String)
List.Item(index) = Value
End Set
End Property
I've two problems-
1. What is the correct syntax for flagging the property as Default?
2. How do I implement the parameter 'index'?
I used an online VB.Net to C# conversion tool which produced the following-
public string Item
{
get
{
return List.Item(index).ToString;
}
set
{
List.Item(index) = value;
}
}
but the 'default' setting is lost and the compiler complains that 'index' isn't defined.
This is such a common and simple pattern I'm struggling to understand where I'm going wrong!!!