静态方法

2018-11-29  本文已影响4人  平凡的鱼仔

c#静态方法特点;

'''

class Test
{
    private static int num = 2;
    private int part = 10;

    public static int getDoubleNum()
    {
       // part += 5; 报错,不能访问非静态成员
       //this.num=5;报错,不能使用this关键字
        return 2 * num;
    }
    static void Main(string[] args)
    {
        Console.ReadKey();
    }
}

'''

上一篇 下一篇

猜你喜欢

热点阅读