public static long Aligned(this long offset, int alignment, long requiredSize) { if (offset / alignment == (offset + requiredSize) / alignment) { return(offset); } if (offset % alignment == 0) { return(offset); } return(offset.Aligned(alignment)); }