0

Hi. In C++ ie we can do this:


code.cpp

#include vars.h


main()
{
if var1 == 1 { printf("ok"); }
return true; }

The point is not the code itself, but that #include.

I'd like to have a *.cs file containing some numeric variables.
But not a Class, just a normal text file containing variables like const int var1 = 1;

How can I do that?

3
Contributors
2
Replies
3
Views
6 Years
Discussion Span
Last Post by ddanbe
0

Read about static
You could do something like this:

class Vars
    {
        public static int var1 = 1;
        public static double var2 = 3.42;
        //etc.
    }

Then use your variables like this:

int i;       
double d = Vars.var2;
i = Vars.var1;
This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.