Global Array Structure

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

    #1

    Global Array Structure

    I am new the C# coming from a VB6 world. In VB6 I have serveral applications
    where I create a UDT in a module then make an array of the UDT. All modules
    and forms could access this. Now I am attempting to do this in C#. I would
    like to create a Structure then an array of that, (ex. Variable[0].Name,
    Variable[0].Value). But I need several classes to have access to the data.
    It must be an array because I update some of the values.

    Another possiblity is to have the array of strucuture in a single class that
    other classes can have access to the data to update.

    Can anyone point me in the right direciton.


  • Randy A. Ynchausti

    #2
    Re: Global Array Structure

    wg,
    [color=blue]
    >I am new the C# coming from a VB6 world. In VB6 I have serveral
    >applications where I create a UDT in a module then make an array of the
    >UDT. All modules and forms could access this. Now I am attempting to do
    >this in C#. I would like to create a Structure then an array of that, (ex.
    >Variable[0].Name, Variable[0].Value). But I need several classes to have
    >access to the data. It must be an array because I update some of the
    >values.
    >
    > Another possiblity is to have the array of strucuture in a single class
    > that other classes can have access to the data to update.
    >
    > Can anyone point me in the right direciton.[/color]

    Create a namespace that will contain these "utility" classes. In that
    namespace, create a public class that exposes public methods (API) that
    define all of the UDT behavior that the application needs. Implement
    private members (fields and methods) that perform the inner workings of the
    class and the API. Once it is working and tested, refactor it to ensure
    that all code is expressed once and only once and that the interface is
    clear and concise. You can then import the namespace and use the UDT class
    and API wherever you need it.

    If you need a single instance for the entire application, implement the
    class using the "Singleton" design pattern.

    To do this, you may have to unlearn some of the VB6 approaches that may be
    part of your developer tricks of the trade. Good luck and I hope this
    helps.

    Regards,

    Randy


    Comment

    • Nicholas Paldino [.NET/C# MVP]

      #3
      Re: Global Array Structure

      wg,

      You will need to declare the array as public and static in order to have
      all other classes access it.

      Hope this helps.


      --
      - Nicholas Paldino [.NET/C# MVP]
      - mvp@spam.guard. caspershouse.co m

      "wg" <wg@hotmail.com > wrote in message
      news:HwgAf.1682 $5O2.661@bignew s4.bellsouth.ne t...[color=blue]
      >I am new the C# coming from a VB6 world. In VB6 I have serveral
      >applications where I create a UDT in a module then make an array of the
      >UDT. All modules and forms could access this. Now I am attempting to do
      >this in C#. I would like to create a Structure then an array of that, (ex.
      >Variable[0].Name, Variable[0].Value). But I need several classes to have
      >access to the data. It must be an array because I update some of the
      >values.
      >
      > Another possiblity is to have the array of strucuture in a single class
      > that other classes can have access to the data to update.
      >
      > Can anyone point me in the right direciton.
      >[/color]


      Comment

      Working...