Outputs as many bytes as necessary to align the output to the specified boundary.

Namespace: SharpAssembler.Core
Assembly: SharpAssembler Core (in SharpAssembler Core.dll) Version: 1.0.0.0 (1.0.0.0)

Syntax

C#
public static long Align(
	this BinaryWriter writer,
	int boundary
)
Visual Basic
<ExtensionAttribute> _
Public Shared Function Align ( _
	writer As BinaryWriter, _
	boundary As Integer _
) As Long
Visual C++
[ExtensionAttribute]
public:
static long long Align(
	BinaryWriter^ writer, 
	int boundary
)

Parameters

writer
Type: System.IO..::..BinaryWriter
The BinaryWriter being used.
boundary
Type: System..::..Int32
The boundary to align the output to. Must be a power of 2.

Return Value

The number of padding bytes used.

Usage Note

In Visual Basic and C#, you can call this method as an instance method on any object of type BinaryWriter. When you use instance method syntax to call this method, omit the first parameter. For more information, see or .

Exceptions

ExceptionCondition
System..::..ArgumentNullExceptionwriter == null
System..::..ArgumentNullException!(MathExt.IsPowerOfTwo(boundary))
System..::..ArgumentOutOfRangeExceptionboundary < 1

Contracts

Requires
writer != null
MathExt.IsPowerOfTwo(boundary)
boundary >= 1
Ensures
Contract.Result<long>() >= 0

See Also