0

This is my class:

 public  class TestClass
 {
    public static int one;
 }

What's the difference between declaring it as this:

public static TestClass test;

and this:

public TestClass test;
Logan Master
  • 33
  • 1
  • 6

1 Answers1

1

You can find answer here

A static method, field, property, or event is callable on a class even when no instance of the class has been created. If any instances of the class are created, they cannot be used to access the static member. Only one copy of static fields and events exists, and static methods and properties can only access static fields and static events. Static members are often used to represent data or calculations that do not change in response to object state; for instance, a math library might contain static methods for calculating sine and cosine. Static class members are declared using the static keyword before the return type of the member, for example:

public class Automobile {
    public static int NumberOfWheels = 4;
    public static int SizeOfGasTank
    {
        get
        {
            return 15;
        }
    }
    public static void Drive() { }
    public static event EventType RunOutOfGas;

    //other non-static fields and properties... }
V. Panchenko
  • 774
  • 1
  • 10
  • 32