TouchSocketBitConverterUnsafeWriteBytesT 方法
不安全地将值直接写入字节数组中。
命名空间: TouchSocket.Core程序集: TouchSocket.Core (在 TouchSocket.Core.dll 中) 版本:3.0.0+ccaf96084d09f972257496d1dd63b8ba3c1e44f0
public int UnsafeWriteBytes<T>(
ref byte source,
T value
)
where T : struct, new()
Public Function UnsafeWriteBytes(Of T As {Structure, New}) (
ByRef source As Byte,
value As T
) As Integer
member UnsafeWriteBytes :
source : byte byref *
value : 'T -> int when 'T : struct, new()
- source Byte
- 指向字节数组的引用,从这里开始写入。
- value T
- 要写入的值。
- T
- 要写入的值的类型,必须是值类型。
Int32写入的字节数。
此方法用于在字节数组中直接插入结构,主要用于性能考虑。
它绕过了C#的类型安全性,因此使用时必须确保T是固定大小的值类型。
如果数据格式不匹配或大小不支持,将抛出异常。