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
CODE PROJECT For Those Who Code
  • Home
  • Articles
  • FAQ
Community
  1. Home
  2. General Programming
  3. C#
  4. Can you pass parameters to properties?

Can you pass parameters to properties?

Scheduled Pinned Locked Moved C#
csharpquestion
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.
  • I Offline
    I Offline
    inyoursadachine
    wrote on last edited by
    #1

    Hi, A while back I was reading about passing parameters to C# properties and loving it. But I must have been dreaming because now (that I'm ready to use them) I can't find any mention of them. Was it only a dream? Thx, MAtt

    G 1 Reply Last reply
    0
    • I inyoursadachine

      Hi, A while back I was reading about passing parameters to C# properties and loving it. But I must have been dreaming because now (that I'm ready to use them) I can't find any mention of them. Was it only a dream? Thx, MAtt

      G Offline
      G Offline
      Gary Thom
      wrote on last edited by
      #2

      No, you can pass parameters like this (excuse the pun)

      public MyObject this[int index]
      {
      get
      {
      return (MyObject) InnerList[index];
      }
      }

      as you can see I've ripped this code from a CollectionBase derived class.

      You can pass more than one param within the [] brackets Gary "A fellow with the inventiveness of Albert Einstein but with the attention span of Daffy Duck." Tom Shales talking about Robin Williams

      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