Class UnsafeExtensions
- Namespace
- Garyon.Extensions
- Assembly
- Garyon.dll
Provides extensions for unsafe context.
public static class UnsafeExtensions
- Inheritance
-
UnsafeExtensions
- Inherited Members
Methods
AsBytes<TSource>(ReadOnlySpan<TSource>)
Converts the given span into a span of bytes.
public static ReadOnlySpan<byte> AsBytes<TSource>(this ReadOnlySpan<TSource> source) where TSource : struct
Parameters
sourceReadOnlySpan<TSource>
Returns
Type Parameters
TSource
Remarks
The actual byte length of the span is preserved, the original span is unaffected and the result reinterprets the same content as a span of bytes.
GetBytes<T>(ref T)
Gets a ReadOnlySpan<T> containing the bytes of the provided value.
public static ReadOnlySpan<byte> GetBytes<T>(this ref T value) where T : unmanaged
Parameters
valueTThe value whose bytes to get.
Returns
- ReadOnlySpan<byte>
The bytes of the value.
Type Parameters
TThe type of the value whose bytes to get.
GetValueFromSpan<T>(Span<byte>)
public static T GetValueFromSpan<T>(this Span<byte> span) where T : unmanaged
Parameters
Returns
- T