class with indexer is not accessible to other language

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

    class with indexer is not accessible to other language

    Hello,

    I have a class with an indexer in the class. The code code is in C#.
    However I was trying to access the indexer in the other lang of .Net,
    VB. I ran into some indexer related issues (I believe they are because
    of indexer)

    Does any one can give me procedure to do the above?

    -Cnu
  • Alberto Poblacion

    #2
    Re: class with indexer is not accessible to other language

    "Duggi" <DuggiSrinivasa Rao@gmail.comwr ote in message
    news:04543ed4-84d6-429f-9482-e19e78329347@s9 g2000prg.google groups.com...
    I have a class with an indexer in the class. The code code is in C#.
    However I was trying to access the indexer in the other lang of .Net,
    VB. I ran into some indexer related issues (I believe they are because
    of indexer)
    >
    Does any one can give me procedure to do the above?

    When you define an indexer in C#, it is accessed from VB.Net as "Item".
    For instance:

    [C#]

    class Whatever
    {
    public string this[int p]
    {
    get { ...; }
    }
    }
    ....
    Whatever x = new Whatever();
    string result = x[7];


    [VB]

    Dim x as New Whatever()
    Dim result as String = x.Item(7)


    Comment

    • Duggi

      #3
      Re: class with indexer is not accessible to other language

      On Sep 27, 1:10 pm, "Alberto Poblacion" <earthling-
      quitaestoparaco ntes...@poblaci on.orgwrote:
      "Duggi" <DuggiSrinivasa ...@gmail.comwr ote in message
      >
      news:04543ed4-84d6-429f-9482-e19e78329347@s9 g2000prg.google groups.com...
      >
      I have a class with an indexer in the class. The code code is in C#.
      However I was trying to access the indexer in the other lang of .Net,
      VB. I ran into some indexer related issues (I believe they are because
      of indexer)
      >
      Does any one can give me procedure to do the above?
      >
          When you define an indexer in C#, it is accessed from VB.Net as "Item".
      For instance:
      >
      [C#]
      >
      class Whatever
      {
         public string this[int p]
         {
            get { ...; }
         }}
      >
      ...
      Whatever x = new Whatever();
      string result = x[7];
      >
      [VB]
      >
      Dim x as New Whatever()
      Dim result as String = x.Item(7)
      Thanks dude!!

      its working.

      -Cnu

      Comment

      • Pavel Minaev

        #4
        Re: class with indexer is not accessible to other language

        On Sep 28, 12:10 am, "Alberto Poblacion" <earthling-
        quitaestoparaco ntes...@poblaci on.orgwrote:
        "Duggi" <DuggiSrinivasa ...@gmail.comwr ote in message
        >
        news:04543ed4-84d6-429f-9482-e19e78329347@s9 g2000prg.google groups.com...
        >
        I have a class with an indexer in the class. The code code is in C#.
        However I was trying to access the indexer in the other lang of .Net,
        VB. I ran into some indexer related issues (I believe they are because
        of indexer)
        >
        Does any one can give me procedure to do the above?
        >
            When you define an indexer in C#, it is accessed from VB.Net as "Item".
        For instance:
        >
        [C#]
        >
        class Whatever
        {
           public string this[int p]
           {
              get { ...; }
           }}
        >
        ...
        Whatever x = new Whatever();
        string result = x[7];
        >
        [VB]
        >
        Dim x as New Whatever()
        Dim result as String = x.Item(7)
        Actually, you should be able to just use x(7) as well.

        Comment

        Working...