Public Class Class1    Public Property Memo(ByVal index As Integer) As String
        Get        End Get
        Set(ByVal Value As String)        End Set
    End Property    Public Property Name(ByVal index As Integer) As String
        Get        End Get
        Set(ByVal Value As String)        End Set
    End Property
End Class我知道可以用索引器,但是由于参数都一样,没办法overload,该如何转换?

解决方案 »

  1.   

    public class Class1{
    //INSTANT C# WARNING: The following VB property was changed to a C# function since C# does not support parameterized properties
    public string Memo(int index)
    {
    get
    { }
    set
    { }
    }//INSTANT C# WARNING: The following VB property was changed to a C# function since C# does not support parameterized properties
    public string Name(int index)
    {
    get
    { }
    set
    { }
    }
    }
    直接用工具转换的,哈哈
      

  2.   

    VB转C#我一般都是编译,然后反编译为C#,保证100%正确~
      

  3.   

    上面的代码我用reflector反编译为c#但通不过c#编译啊!
    看来有点难度.
      

  4.   

    上面用工具转的,有问题,应该把()改为[]:
    public string Name[int index]
    {
    get
    { }
    set
    { }
    }
      

  5.   

    一楼的注释都说得很清楚:C#不支持参数化的属性,只能改成函数,但是函数可以有get,set吗?这个问题恐怕是不能直接转换,2个属性要转换为4个函数才可以.
      

  6.   

    public class Class1 
    {  public string Memo { 
       get { 
       } 
       set { 
       } 
     }  public string Name { 
       get { 
       } 
       set { 
       } 
     } 
    }