得到数组的长度

use*_*681 2 .net c# arrays reflection

所以我上了这堂课:

    public class MyClass{
        public int[] myArray = new int[9];
    }
Run Code Online (Sandbox Code Playgroud)

我可以在不需要初始化MyClass实例的情况下获取数组的长度吗?

Cod*_*ter 8

无需初始化MyClass的实例

否.= new int[9]将移动到构造函数,该构造函数仅在您实例化类时才运行.