Results 1 to 7 of 7

Thread: Classes

  1. #1

    Thread Starter
    Frenzied Member
    Join Date
    Jun 2001
    Location
    USA
    Posts
    1,026

    Unhappy Classes

    I would like to create a class called "group" and within that class have an array of obects ("members')... Each member has two properties... name and id...

    Here's my problem...

    I am not sure how I would keep the array of member objects within the Group object...

    And what is the syntax for the constructor of a new member?

    Thanks,

    Squirrelly1
    Now happily married and still crankin' away at the keyboard. Life is grand for a coder, no?

  2. #2

    Thread Starter
    Frenzied Member
    Join Date
    Jun 2001
    Location
    USA
    Posts
    1,026
    And one more thing...


    Where in the world is the BinaryFormatter object?


    Thanx,

    Squirrelly1
    Now happily married and still crankin' away at the keyboard. Life is grand for a coder, no?

  3. #3

    Thread Starter
    Frenzied Member
    Join Date
    Jun 2001
    Location
    USA
    Posts
    1,026
    Update...

    I found the binaryformatter...

    it's in

    System.Runtime.Serialize(something like that).Formatters.Binary.BinaryFormatter


    or something to that effect


    Squirrelly1...
    Now happily married and still crankin' away at the keyboard. Life is grand for a coder, no?

  4. #4
    Your Ad Here! Edneeis's Avatar
    Join Date
    Feb 2000
    Location
    Moreno Valley, CA (SoCal)
    Posts
    7,339
    The BinaryFormatter object is what does Binary Serialization.

    I would suggest using a collection instead of an array but I'll use an array since you mentioned it. You just make the array a property of the group object.

    VB Code:
    1. Public Class Member
    2.  
    3.     Private _Id As Integer = 0
    4.     Private _Name As String = String.Empty
    5.  
    6.     Public Property Id() As Integer
    7.         Get
    8.             Return _Id
    9.         End Get
    10.         Set(ByVal Value As Integer)
    11.             _Id = Value
    12.         End Set
    13.     End Property
    14.  
    15.     Public Property Name() As String
    16.         Get
    17.             Return _Name
    18.         End Get
    19.         Set(ByVal Value As String)
    20.             _Name = Value
    21.         End Set
    22.     End Property
    23.  
    24.     Public Sub New()
    25.         'default
    26.     End Sub
    27.  
    28.     Public Sub New(ByVal id As Integer, ByVal name As String)
    29.         Me.Id = id
    30.         Me.Name = name
    31.     End Sub
    32.  
    33. End Class
    34.  
    35. Public Class Group
    36.  
    37.     Private _Name As String = String.Empty
    38.     Private _Members As Member()
    39.  
    40.     Public Property Name() As String
    41.         Get
    42.             Return _Name
    43.         End Get
    44.         Set(ByVal Value As String)
    45.             _Name = Value
    46.         End Set
    47.     End Property
    48.  
    49.     Public Property Members() As Member()
    50.         Get
    51.             Return _Members
    52.         End Get
    53.         Set(ByVal Value As Member())
    54.             _Members = Value
    55.         End Set
    56.     End Property
    57.  
    58.     Public Sub New()
    59.         'default
    60.     End Sub
    61.  
    62.     Public Sub New(ByVal name As String, ByVal members() As Member)
    63.         Me.Name = name
    64.         Me.Members = members
    65.     End Sub
    66.  
    67. End Class

  5. #5

    Thread Starter
    Frenzied Member
    Join Date
    Jun 2001
    Location
    USA
    Posts
    1,026
    What does the underscore represent in your code?

    Oh, btw... I decided to use a collection... Those SOBs work wonders!!! LOL


    Squirrelly1
    Now happily married and still crankin' away at the keyboard. Life is grand for a coder, no?

  6. #6
    Your Ad Here! Edneeis's Avatar
    Join Date
    Feb 2000
    Location
    Moreno Valley, CA (SoCal)
    Posts
    7,339
    The underscore doesn't mean a damn thing really its just my naming convention for member variables. Some people use m_ or an abbreviation of the type bln, str, int but I like just _.

  7. #7

    Thread Starter
    Frenzied Member
    Join Date
    Jun 2001
    Location
    USA
    Posts
    1,026
    I knew it was a naming convention of sorts, but I had never seen it before...

    Squirrelly1
    Now happily married and still crankin' away at the keyboard. Life is grand for a coder, no?

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