Can't create static variable inside a static method?

前端 未结 4 1112
夕颜
夕颜 2021-01-24 23:44

Why won\'t this work?

public static int[] GetListOfAllDaysForMonths()
{
    static int[] MonthDays = new int[] {1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,2         


        
4条回答
  •  执念已碎
    2021-01-25 00:37

    Well, apart from it not being supported, why would you want to? If you need to define something inside a method, it has local scope, and clearly doesn't need anything more than that.

提交回复
热议问题