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. What is it called when your class has a root collection and how do you do it in C#?

What is it called when your class has a root collection and how do you do it in C#?

Scheduled Pinned Locked Moved C#
questioncsharp
5 Posts 3 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.
  • Q Offline
    Q Offline
    qmuffs
    wrote on last edited by
    #1

    public class UserSettings { public UserSettings[] { } } so that I can access it like so: Console.WriteLine(UserSetting["ITEMNAME"]); Thank you to everyone in advance.

    QMuffs

    P K 2 Replies Last reply
    0
    • Q qmuffs

      public class UserSettings { public UserSettings[] { } } so that I can access it like so: Console.WriteLine(UserSetting["ITEMNAME"]); Thank you to everyone in advance.

      QMuffs

      P Offline
      P Offline
      Paul Conrad
      wrote on last edited by
      #2

      What are you trying to accomplish?

      "The clue train passed his station without stopping." - John Simmons / outlaw programmer "Real programmers just throw a bunch of 1s and 0s at the computer to see what sticks" - Pete O'Hanlon

      Q 1 Reply Last reply
      0
      • P Paul Conrad

        What are you trying to accomplish?

        "The clue train passed his station without stopping." - John Simmons / outlaw programmer "Real programmers just throw a bunch of 1s and 0s at the computer to see what sticks" - Pete O'Hanlon

        Q Offline
        Q Offline
        qmuffs
        wrote on last edited by
        #3

        I think it is called an accessor to my class but I'm not sure. Let's say I have this UserSettings["ITEMNAME"] When it does this I have to Validate the ItemName and return the default if it doesn't exist. I basically want the [] to act as a property in a way. Would it be an operator?

        QMuffs

        1 Reply Last reply
        0
        • Q qmuffs

          public class UserSettings { public UserSettings[] { } } so that I can access it like so: Console.WriteLine(UserSetting["ITEMNAME"]); Thank you to everyone in advance.

          QMuffs

          K Offline
          K Offline
          Karthik Kalyanasundaram
          wrote on last edited by
          #4

          I think C# Indexers can help you. Please check this link to know more about Indexers Indexer In C#[^]

          Software - Bundle of bugs covered with features.

          Q 1 Reply Last reply
          0
          • K Karthik Kalyanasundaram

            I think C# Indexers can help you. Please check this link to know more about Indexers Indexer In C#[^]

            Software - Bundle of bugs covered with features.

            Q Offline
            Q Offline
            qmuffs
            wrote on last edited by
            #5

            That is it. I did it before but couldn't remember how or what it was called. I was looking everywhere. You saved me from going insane. Thank you very much.

            QMuffs

            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