Current location - Plastic Surgery and Aesthetics Network - Plastic surgery and beauty - C# defines global static variables, help!
C# defines global static variables, help!
This is what we often call "attribute".

Answer your question first:

1._NAME is a variable. And Name is an open interface. It is underlined because of the naming rules.

2. Static strings are actually private static strings.

In C#, variables without modifiers default to private variables. Why do you need to restrict private variables here?

This is the advantage of "attribute". It encapsulates the business logic. ..

3. Attributes are controllable. Writeable or readable or both.

When we need to get the name, we just need to write the global variable. The name is on the right of the equal sign.

For example, the string cName = Globals. Name;

When we need to set a name, we just need to write a global variable. The name is on the left of the equal sign.

For example: Globals. Name = "Suki";

When using global variables. Name = "Suki" and value is Suki.

Get is readable. The collection is writable. There are both get and set, which means both reading and writing.

In fact, your 1 contact may not be familiar with it. It is not surprising to write too much, because his format is fixed. It just changes the code in get or set.