Difference between static, readonly, and constant in C# (part 1)
static:
🔸 Declared using the
🔸 Classes, constructors, methods, variables, properties, event and operators can be static. The struct, indexers, enum, destructors, or finalizers cannot be static.
🔸 Static members can only be accessed within the static methods. The non-static methods cannot access static members.
🔸 Value of the static members can be modified using
🔸 Static members can be accessed using
static:
🔸 Declared using the
static
keyword.🔸 Classes, constructors, methods, variables, properties, event and operators can be static. The struct, indexers, enum, destructors, or finalizers cannot be static.
🔸 Static members can only be accessed within the static methods. The non-static methods cannot access static members.
🔸 Value of the static members can be modified using
ClassName.StaticMemberName
.🔸 Static members can be accessed using
ClassName.StaticMemberName
, but cannot be accessed using object.