#include or including files
-
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
-
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
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.
-
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
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 asGlobal.Foo
, etc. Perhaps others have a more elegant way.CQ de W5ALT
Walt Fair, Jr., P. E. Comport Computing Specializing in Technical Engineering Software
-
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
Ooor... pass your C# code through a C-preprocessor; there's nothing stopping you. :cool:
-
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.
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.
-
Ooor... pass your C# code through a C-preprocessor; there's nothing stopping you. :cool:
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.
-
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.
-
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.
Yep, I almost expected someone to have already replied saying just wait until I got on. :-D