Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C#
  4. between a property and an indexer

between a property and an indexer

Scheduled Pinned Locked Moved C#
questioncsharpdata-structurestutoriallearning
2 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • R Offline
    R Offline
    Rupel
    wrote on last edited by
    #1

    hiho, i think those properties are a nice new thing in c#. is there a way to have an array as a property? indexers are on a by-class-basis (so to say), so is there anything between? imagine a table-class. i want something like myTable.RowName[6]="Street"; myTyble.Cell[3,7] = 87; so, how to define RowName or Cell of course i can do it the old-fashioned way using member-functions a la myTable.SetRowname(6,"Street") or the other way around, make the array public, but then the user of my class is responsible for the range-checking. X| ok, the question in short again: can i have an array as a property? if yes, how? thx in advance. :wq

    N 1 Reply Last reply
    0
    • R Rupel

      hiho, i think those properties are a nice new thing in c#. is there a way to have an array as a property? indexers are on a by-class-basis (so to say), so is there anything between? imagine a table-class. i want something like myTable.RowName[6]="Street"; myTyble.Cell[3,7] = 87; so, how to define RowName or Cell of course i can do it the old-fashioned way using member-functions a la myTable.SetRowname(6,"Street") or the other way around, make the array public, but then the user of my class is responsible for the range-checking. X| ok, the question in short again: can i have an array as a property? if yes, how? thx in advance. :wq

      N Offline
      N Offline
      Neil Van Note
      wrote on last edited by
      #2

      You can define a property that returns a reference to an array. Also, there is nothing stopping you from returning a reference to class that defines an indexer with multiple parameters. Either way, it should work as you stated above... Regards

      1 Reply Last reply
      0
      Reply
      • Reply as topic
      Log in to reply
      • Oldest to Newest
      • Newest to Oldest
      • Most Votes


      • Login

      • Don't have an account? Register

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • World
      • Users
      • Groups