注意:bool会被视为1位,即1/8字节,而其他非托管类型会按字节计算。
public static int GetConvertedLength<TSource, TTarget>(
int length
)
where TSource : struct, new()
where TTarget : struct, new()
Public Shared Function GetConvertedLength(Of TSource As {Structure, New}, TTarget As {Structure, New}) (
length As Integer
) As Integerstatic member GetConvertedLength :
length : int -> int when 'TSource : struct, new() when 'TTarget : struct, new()| InvalidOperationException | 当目标类型的大小为零时抛出。 |
| ArgumentException | 当源类型的比特数不能被目标类型的比特数整除时抛出。 |
| OverflowException | 当转换后的长度超过 MaxValue 时抛出。 |