Results 1 to 5 of 5

Thread: sub properties

  1. #1

    Thread Starter
    Hyperactive Member noble's Avatar
    Join Date
    Nov 2000
    Location
    Philly
    Posts
    471
    how do u create sub properties for a property in a class?

    If there is a module titled "Person" and a property titled
    "Hand", how do i create a property titled "Left" that
    will be a property of Hand?

    Person.Hand.Left= blahblahblah

    thx for any help
    Bababooey
    Tatatoothy
    Mamamonkey

  2. #2
    Banished Cander's Avatar
    Join Date
    Dec 2000
    Location
    Why do you care?
    Posts
    6,913
    Create a class with right and left properties ten declare Hand as that class.
    Stack Overflow
    See the features of Visual Studio 2010 and C# 4.0: The 10-4 show on Channel9

  3. #3

    Thread Starter
    Hyperactive Member noble's Avatar
    Join Date
    Nov 2000
    Location
    Philly
    Posts
    471
    yes but hand is a property of person, and i don't think
    i ever had to create more and more cls modules based
    on how many sub properties i had for a class

    if i had
    Person.Hand.Left
    Person.Hand.Right
    Person.Leg.Left
    Person.Leg.Right
    i would need 3 cls modules......1 for person, 1 for hand, and
    1 for leg where hand and leg are sub properties of the
    person class

    i did this before and i don't think this is how i went about
    it.
    Bababooey
    Tatatoothy
    Mamamonkey

  4. #4
    Hyperactive Member
    Join Date
    Mar 2000
    Location
    Boulder, Colorado, USA
    Posts
    325
    the proper OOP way of doing this is:

    Person has a left_hand
    has a right_hand
    has a left_leg
    has_a right_leg


    all of which are classes. you might even have all the body parts inherit from a super class like body_parts. s you can have Person has many body_parts.

    anyways, VB OOP is silly (read as sucks).
    -Shickadance

  5. #5
    Banished Cander's Avatar
    Join Date
    Dec 2000
    Location
    Why do you care?
    Posts
    6,913
    Which bings me to another point. You would be coding an extra property for no reason

    Look at this
    Hand property with 2 properties
    Left and Right

    Vs.
    HandLeft
    HandRight


    There is no point in writting useless code.
    Stack Overflow
    See the features of Visual Studio 2010 and C# 4.0: The 10-4 show on Channel9

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width