DEV Community

Cover image for C# Static Variables
Saoud
Saoud

Posted on

C# Static Variables

Terminology

Static method: A method called on a class.

Static variable: A variable scoped to the class.

Declaring Static Variables

A static variable includes the static keyword. For instance:

private static List<Item> _instances = new List<Item> {};
Enter fullscreen mode Exit fullscreen mode

Static variable names always begin with an _.

Top comments (0)

👋 Kindness is contagious

Engage with a wealth of insights in this thoughtful article, valued within the supportive DEV Community. Coders of every background are welcome to join in and add to our collective wisdom.

A sincere "thank you" often brightens someone’s day. Share your gratitude in the comments below!

On DEV, the act of sharing knowledge eases our journey and fortifies our community ties. Found value in this? A quick thank you to the author can make a significant impact.

Okay