/// <summary> /// /// </summary> /// <typeparam name="T"></typeparam> /// <param name="memory"></param> /// <param name="t"></param> /// <returns>T size</returns> public unsafe static int Write <T>(this Memory <byte> memory, ref T t) where T : unmanaged { var p = (T *)memory.Pin().Pointer; *p = t; return(sizeof(T)); }