- android - RelativeLayout 背景可绘制重叠内容
- android - 如何链接 cpufeatures lib 以获取 native android 库?
- java - OnItemClickListener 不起作用,但 OnLongItemClickListener 在自定义 ListView 中起作用
- java - Android 文件转字符串
根据 vs 的文档:MakeArrayType()
表示下限为零的一维数组。 MakeArrayType(1)
表示具有指定维数的数组。例如,如果 UnderlyingSystemType 是 int
,则 MakeArrayType()
的返回类型是System.Int32[]
并且 MakeArrayType(1)
的返回类型是 System.Int32[*]
。
这些类型之间有什么区别。
最佳答案
正如您从返回的类型(Int32[ ]
与 Int32[*]
)。根据 .MakeArrayType()
的文档:
Note: The common language runtime makes a distinction between vectors (that is, one-dimensional arrays that are always zero-based) and multidimensional arrays. A vector, which always has only one dimension, is not the same as a multidimensional array that happens to have only one dimension. This method overload can only be used to create vector types, and it is the only way to create a vector type. Use the MakeArrayType(Int32) method overload to create multidimensional array types. Source
因此,当您调用 .MakeArrayType()
时,它会返回一个 Vector(这是一种始终具有一维的特殊事物)。调用 .MakeArrayType(1)
生成多维数组(不是 Vector)——恰好它只有一个维度。
Vector 和 Array 之间的区别非常技术性,但基本上 Vectors 得到了 CLR 的特殊处理,因此有额外的 IL 指令可以与它们一起使用并且可以使它们更高效。有关数组和向量之间差异的更多信息,请参阅:http://markettorrent.com/community/7968#Vectors vs. Arrays
关于c# - .MakeArrayType() 和 .MakeArrayType(1) 的区别,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7057951/
根据 vs 的文档:MakeArrayType() 表示下限为零的一维数组。 MakeArrayType(1) 表示具有指定维数的数组。例如,如果 UnderlyingSystemType 是 int
我是一名优秀的程序员,十分优秀!