Array of classes

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • hjackman

    #1

    Array of classes

    I have a class with several properties and methods that manipulate unmanaged
    memory. When I need more memory, I simple create another class and add the
    class to an array. My question is such: When I create a new instance of
    the class, are the methods shared by all instances of the class or are they
    also reallocated with each new instance of the class?


  • T3rM1ght

    #2
    Re: Array of classes

    Im not to sure on the terminology included in your post, but I have
    this code within my application to create a new instance of a form
    class.

    =============== =============== =====
    Dim Frm As New frmMain()
    Me.AddOwnedForm (Frm)
    Frm.Show()
    =============== =============== =====

    and to cycle through the list of owned forms, just use a for loop sort
    of like this:

    =============== =============== =====
    Dim frm As frmMain
    For Each frm In Me.OwnedForms

    <Code to be executed in here>

    Next frm
    =============== =============== =====


    I hope that helps.

    Comment

    • Mattias Sjögren

      #3
      Re: Array of classes

      [color=blue]
      >When I create a new instance of
      >the class, are the methods shared by all instances of the class[/color]

      Yes


      Mattias

      --
      Mattias Sjögren [MVP] mattias @ mvps.org
      http://www.msjogren.net/dotnet/ | http://www.dotnetinterop.com
      Please reply only to the newsgroup.

      Comment

      • Michael D. Ober

        #4
        Re: Array of classes


        But the private data isn't.

        Mike Ober.

        "Mattias Sjögren" <mattias.dont.w ant.spam@mvps.o rg> wrote in message
        news:uBfAQci0FH A.2064@TK2MSFTN GP09.phx.gbl...[color=blue]
        >[color=green]
        > >When I create a new instance of
        > >the class, are the methods shared by all instances of the class[/color]
        >
        > Yes
        >
        >
        > Mattias
        >
        > --
        > Mattias Sjögren [MVP] mattias @ mvps.org
        > http://www.msjogren.net/dotnet/ | http://www.dotnetinterop.com
        > Please reply only to the newsgroup.[/color]



        Comment

        Working...