Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C#
  4. #include or including files

#include or including files

Scheduled Pinned Locked Moved C#
questioncsharp
8 Posts 5 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • P Offline
    P Offline
    prithaa
    wrote on last edited by
    #1

    Hello, I want to include a file which contains the basic string values that are required by my system.There is no #include file.h support for C# . Is there any way where I can define global variables so that they are available for all my forms and files in the project? HOw can i do that ? Thanks

    S D P 3 Replies Last reply
    0
    • P prithaa

      Hello, I want to include a file which contains the basic string values that are required by my system.There is no #include file.h support for C# . Is there any way where I can define global variables so that they are available for all my forms and files in the project? HOw can i do that ? Thanks

      S Offline
      S Offline
      Sasa Cetkovic
      wrote on last edited by
      #2

      The only thing you can do is put all your variables in a public static class and put that class inside your project's namespace. You can then access them with className.variableName. If you declare them as public also, of course.

      P 1 Reply Last reply
      0
      • P prithaa

        Hello, I want to include a file which contains the basic string values that are required by my system.There is no #include file.h support for C# . Is there any way where I can define global variables so that they are available for all my forms and files in the project? HOw can i do that ? Thanks

        D Offline
        D Offline
        Dr Walt Fair PE
        wrote on last edited by
        #3

        Well, that's one of the things you'll have to get used to with C#. I usually define a Global class that contains all my constants and true global variables. Just reference it and use the constants/variables or refer to them as Global.Foo, etc. Perhaps others have a more elegant way.

        CQ de W5ALT

        Walt Fair, Jr., P. E. Comport Computing Specializing in Technical Engineering Software

        1 Reply Last reply
        0
        • P prithaa

          Hello, I want to include a file which contains the basic string values that are required by my system.There is no #include file.h support for C# . Is there any way where I can define global variables so that they are available for all my forms and files in the project? HOw can i do that ? Thanks

          P Offline
          P Offline
          PIEBALDconsult
          wrote on last edited by
          #4

          Ooor... pass your C# code through a C-preprocessor; there's nothing stopping you. :cool:

          L 1 Reply Last reply
          0
          • S Sasa Cetkovic

            The only thing you can do is put all your variables in a public static class and put that class inside your project's namespace. You can then access them with className.variableName. If you declare them as public also, of course.

            P Offline
            P Offline
            PIEBALDconsult
            wrote on last edited by
            #5

            XajniN wrote:

            The only thing you can do

            Not at all; that may be recommended, but there are several ways to skin this cat. Database, config file, resource file (as far as I know), an enumeration may be of use too.

            1 Reply Last reply
            0
            • P PIEBALDconsult

              Ooor... pass your C# code through a C-preprocessor; there's nothing stopping you. :cool:

              L Offline
              L Offline
              Luc Pattyn
              wrote on last edited by
              #6

              I knew I would read such a reply by you right when I saw the question. :laugh: :laugh:

              Luc Pattyn [Forum Guidelines] [Why QA sucks] [My Articles]


              Getting an article published on CodeProject now is hard and not sufficiently rewarded.


              P P 2 Replies Last reply
              0
              • L Luc Pattyn

                I knew I would read such a reply by you right when I saw the question. :laugh: :laugh:

                Luc Pattyn [Forum Guidelines] [Why QA sucks] [My Articles]


                Getting an article published on CodeProject now is hard and not sufficiently rewarded.


                P Offline
                P Offline
                prithaa
                wrote on last edited by
                #7

                Hey guys thanks for all ur suggestions. Prithaa

                1 Reply Last reply
                0
                • L Luc Pattyn

                  I knew I would read such a reply by you right when I saw the question. :laugh: :laugh:

                  Luc Pattyn [Forum Guidelines] [Why QA sucks] [My Articles]


                  Getting an article published on CodeProject now is hard and not sufficiently rewarded.


                  P Offline
                  P Offline
                  PIEBALDconsult
                  wrote on last edited by
                  #8

                  Yep, I almost expected someone to have already replied saying just wait until I got on. :-D

                  1 Reply Last reply
                  0
                  Reply
                  • Reply as topic
                  Log in to reply
                  • Oldest to Newest
                  • Newest to Oldest
                  • Most Votes


                  • Login

                  • Don't have an account? Register

                  • Login or register to search.
                  • First post
                    Last post
                  0
                  • Categories
                  • Recent
                  • Tags
                  • Popular
                  • World
                  • Users
                  • Groups