Global variables in Visual C#

前端 未结 4 535
花落未央
花落未央 2021-01-21 03:15

How do I declare global variables in Visual C#?

4条回答
  •  悲&欢浪女
    2021-01-21 03:48

    Use the const keyword:

    public const int MAXIMUM_CACHE_SIZE = 100;
    

    Put it in a static class eg

    public class Globals
    {
        public const int MAXIMUM_CACHE_SIZE = 100;
    }
    

    And you have a global variable class :)

提交回复
热议问题