Example #1
0
 /// <summary>
 /// Computes the size of the struct array. Only use if the type is blittable, where marshaling by the runtime is NOT required
 /// (e.g. does not have MarshalAs attributes and can have its raw bytes copied), otherwise use the Marshal SizeOf methods for non-blittable types.
 /// </summary>
 /// <typeparam name="T">Struct type</typeparam>
 /// <param name="array">Array of structs</param>
 /// <returns>Total size, in bytes, of the array's contents.</returns>
 public static int SizeOf <T>(T[] array) where T : struct
 {
     return(array == null ? 0 : array.Length *InternalInterop.SizeOfInline <T>());
 }
Example #2
0
 /// <summary>
 /// Computes the size of the struct type. Only use if the type is blittable, where marshaling by the runtime is NOT required
 /// (e.g. does not have MarshalAs attributes and can have its raw bytes copied), otherwise use the Marshal SizeOf methods for non-blittable types.
 /// </summary>
 /// <typeparam name="T">Struct type</typeparam>
 /// <returns>Size of the struct in bytes.</returns>
 public static unsafe int SizeOf <T>() where T : struct
 {
     return(InternalInterop.SizeOfInline <T>());
 }