Indexers

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • SalamElias

    #1

    Indexers

    Can we code indexers in VB 2005 as in C#? if not what is the corresponding
    feature.
    Thanks
  • David Anton

    #2
    RE: Indexers

    Public Class ClassWithIndexe r
    Private x As Integer()
    Public Default Property Item(ByVal index As Integer) As Integer
    Get
    Return x(index)
    End Get
    Set
    x(index) = Value
    End Set
    End Property
    End Class

    The above VB code is the equivalent for the following C# code:
    public class ClassWithIndexe r
    {
    private int[] x;
    public int this[int index]
    {
    get
    {
    return x[index];
    }
    set
    {
    x[index] = value;
    }
    }
    }
    --
    David Anton
    Source code converters: Convert between C#, C++, Java, and VB with the most accurate and reliable source code converters

    Instant C#: VB to C# converter
    Instant VB: C# to VB converter
    Instant C++: C#/VB to C++ converter
    C# Code Metrics: Quick metrics for C#


    "SalamElias " wrote:
    Can we code indexers in VB 2005 as in C#? if not what is the corresponding
    feature.
    Thanks

    Comment

    • SalamElias

      #3
      RE: Indexers

      Thanks, have a good day

      "David Anton" wrote:
      Public Class ClassWithIndexe r
      Private x As Integer()
      Public Default Property Item(ByVal index As Integer) As Integer
      Get
      Return x(index)
      End Get
      Set
      x(index) = Value
      End Set
      End Property
      End Class
      >
      The above VB code is the equivalent for the following C# code:
      public class ClassWithIndexe r
      {
      private int[] x;
      public int this[int index]
      {
      get
      {
      return x[index];
      }
      set
      {
      x[index] = value;
      }
      }
      }
      --
      David Anton
      Source code converters: Convert between C#, C++, Java, and VB with the most accurate and reliable source code converters

      Instant C#: VB to C# converter
      Instant VB: C# to VB converter
      Instant C++: C#/VB to C++ converter
      C# Code Metrics: Quick metrics for C#
      >
      >
      "SalamElias " wrote:
      >
      Can we code indexers in VB 2005 as in C#? if not what is the corresponding
      feature.
      Thanks

      Comment

      Working...