/// <summary> /// Return the sizeof an array of struct. Equivalent to sizeof operator but works on generics too. /// </summary> /// <typeparam name="T">a struct</typeparam> /// <param name="array">The array of struct to evaluate.</param> /// <returns>sizeof in bytes of this array of struct</returns> public static int SizeOf <T>(T[] array) where T : struct { return(array == null ? 0 : array.Length *Interop.SizeOf <T>()); }
/// <summary> /// Return the sizeof a struct from a CLR. Equivalent to sizeof operator but works on generics too. /// </summary> /// <typeparam name="T">a struct to evaluate</typeparam> /// <returns>sizeof this struct</returns> internal static int UnsafeSizeOf <T>() { return(Interop.SizeOf <T>()); }
/// <summary> /// Return the sizeof a struct from a CLR. Equivalent to sizeof operator but works on generics too. /// </summary> /// <typeparam name="T">a struct to evaluate</typeparam> /// <returns>sizeof this struct</returns> public static int SizeOf <T>() where T : struct { return(Interop.SizeOf <T>()); }