It works fine for me when I try it. Greg
-----Original Message----- From: [email protected] [mailto:[email protected]] On Behalf Of neuromancer Sent: Friday, May 14, 2010 7:12 AM To: DotNetDevelopment, VB.NET, C# .NET, ADO.NET, ASP.NET, XML, XML Web Services,.NET Remoting Subject: [DotNetDevelopment] For static class, I get message: "object reference not set to an instance"! 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
