I am new to C#. I wanted to create a "global" variable, and I found
advice on the net that said create a static class and make a variable
in it, and that will be your global variable.
So I made:
public static class Class1
{
static private int uc;
public static int urlcount
{
get
{
return uc;
}
set
{
uc = value;
}
}
}
Then in my main program, I tried to so something like:
Class1.urlcount = 5;
This should work. I should not need to create an instance of Class1,
because it is a static class. But it does not work. Instead I get
the error message:
"object reference not set to an instance of an object".
What am I missing?
Thanks,
NM