DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

Results 1 to 6 of 6

Thread: Basic Question

  1. #1
    Michael Guest

    Basic Question


    Hello,

    In vb.net I can do this and thus have a global varaible,
    how would I acheive this in C#?

    Module Main
    Public g_ConnStrings As NWDSAConnStrings
    End Module


    Thanks
    Michael

  2. #2
    Brian Preston Guest

    Re: Basic Question


    "Michael" <mrwassermann@netscape.net> wrote:
    >
    >Hello,
    >
    >In vb.net I can do this and thus have a global varaible,
    >how would I acheive this in C#?
    >
    >Module Main
    > Public g_ConnStrings As NWDSAConnStrings
    >End Module
    >
    >
    >Thanks
    >Michael


    class A
    {
    static int x;
    }

    A.x = 10;

    Brian


  3. #3
    Brian Preston Guest

    Re: Basic Question


    "Brian Preston" <brian81@yahoo.com> wrote:
    >
    >"Michael" <mrwassermann@netscape.net> wrote:
    >>
    >>Hello,
    >>
    >>In vb.net I can do this and thus have a global varaible,
    >>how would I acheive this in C#?
    >>
    >>Module Main
    >> Public g_ConnStrings As NWDSAConnStrings
    >>End Module
    >>
    >>
    >>Thanks
    >>Michael

    >
    >class A
    >{
    > static int x;
    >}
    >
    >A.x = 10;
    >
    >Brian
    >


    Oops, forgot to make public

    public class A
    {
    public static int x;
    }

    Brian

  4. #4
    blob Guest

    Re: Basic Question


    "Brian Preston" <brian81@yahoo.com> wrote:
    >
    >"Brian Preston" <brian81@yahoo.com> wrote:
    >>
    >>"Michael" <mrwassermann@netscape.net> wrote:
    >>>
    >>>Hello,
    >>>
    >>>In vb.net I can do this and thus have a global varaible,
    >>>how would I acheive this in C#?
    >>>
    >>>Module Main
    >>> Public g_ConnStrings As NWDSAConnStrings
    >>>End Module
    >>>
    >>>
    >>>Thanks
    >>>Michael

    >>
    >>class A
    >>{
    >> static int x;
    >>}
    >>
    >>A.x = 10;
    >>
    >>Brian
    >>

    >
    >Oops, forgot to make public
    >
    >public class A
    >{
    > public static int x;
    >}
    >
    >Brian



    A better approach would be to create NWDSAConnStrings as a singleton

  5. #5
    Brian Preston Guest

    Re: Basic Question


    "blob" <blob@blobbloblboblo.com> wrote:
    >
    >"Brian Preston" <brian81@yahoo.com> wrote:
    >>
    >>"Brian Preston" <brian81@yahoo.com> wrote:
    >>>
    >>>"Michael" <mrwassermann@netscape.net> wrote:
    >>>>
    >>>>Hello,
    >>>>
    >>>>In vb.net I can do this and thus have a global varaible,
    >>>>how would I acheive this in C#?
    >>>>
    >>>>Module Main
    >>>> Public g_ConnStrings As NWDSAConnStrings
    >>>>End Module
    >>>>
    >>>>
    >>>>Thanks
    >>>>Michael
    >>>
    >>>class A
    >>>{
    >>> static int x;
    >>>}
    >>>
    >>>A.x = 10;
    >>>
    >>>Brian
    >>>

    >>
    >>Oops, forgot to make public
    >>
    >>public class A
    >>{
    >> public static int x;
    >>}
    >>
    >>Brian

    >
    >
    >A better approach would be to create NWDSAConnStrings as a singleton


    Well if there should only and always be single global instance of NWDSAConnStrings,
    but no info was given about this class. It may be used all over the place
    for all I know.

    Brian

  6. #6
    blob Guest

    Re: Basic Question


    "Brian Preston" <brian81@yahoo.com> wrote:
    >
    >"blob" <blob@blobbloblboblo.com> wrote:
    >>
    >>"Brian Preston" <brian81@yahoo.com> wrote:
    >>>
    >>>"Brian Preston" <brian81@yahoo.com> wrote:
    >>>>
    >>>>"Michael" <mrwassermann@netscape.net> wrote:
    >>>>>
    >>>>>Hello,
    >>>>>
    >>>>>In vb.net I can do this and thus have a global varaible,
    >>>>>how would I acheive this in C#?
    >>>>>
    >>>>>Module Main
    >>>>> Public g_ConnStrings As NWDSAConnStrings
    >>>>>End Module
    >>>>>
    >>>>>
    >>>>>Thanks
    >>>>>Michael
    >>>>
    >>>>class A
    >>>>{
    >>>> static int x;
    >>>>}
    >>>>
    >>>>A.x = 10;
    >>>>
    >>>>Brian
    >>>>
    >>>
    >>>Oops, forgot to make public
    >>>
    >>>public class A
    >>>{
    >>> public static int x;
    >>>}
    >>>
    >>>Brian

    >>
    >>
    >>A better approach would be to create NWDSAConnStrings as a singleton

    >
    >Well if there should only and always be single global instance of NWDSAConnStrings,
    >but no info was given about this class. It may be used all over the place
    >for all I know.


    And in this instance or in the case of a singleton it may not be used all
    over the place? And the "g_" usually represents global.


Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center
 
 
FAQ
Latest Articles
Java
.NET
XML
Database
Enterprise
Questions? Contact us.
C++
Web Development
Wireless
Latest Tips
Open Source


   Development Centers

   -- Android Development Center
   -- Cloud Development Project Center
   -- HTML5 Development Center
   -- Windows Mobile Development Center