About the establishment of global variables in C #

Source: Internet
Author: User

Recently, I was working on a mobile development project. I needed a global class method to be called in various forms. After searching for it online for a long time, I finally solved the problem. How to declare the entireProgramCan all access its instances? The following method is used to create

Create a class to store global variables for ease of management. Then, declare the class instance in the class as follows:

Public static user class variable name = new user class ()
;

We need to know that we must use static in declaring global classes. We can use the above form to create an instance so that each form can call it.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.