BsonExtensionMethodsToBson Method (Object, Type, IBsonSerializationOptions)MongoDB C# Driver API Documentation
Converts an object to a BSON document byte array.

Namespace: MongoDB.Bson
Assembly: MongoDB.Bson (in MongoDB.Bson.dll) Version: { version: '1.11.0.92', semver: '1.11.0', commit: '791a16588d4a8b3b118a8b3b57cfa436fec5d3da', commitDate: '2015-12-08 22:55:45' }
Syntax

public static byte[] ToBson(
	this Object obj,
	Type nominalType,
	IBsonSerializationOptions options
)

Parameters

obj
Type: SystemObject
The object.
nominalType
Type: SystemType
The nominal type of the object.
options
Type: MongoDB.Bson.SerializationIBsonSerializationOptions
The serialization options.

Return Value

Type: Byte
A byte array.

Usage Note

In Visual Basic and C#, you can call this method as an instance method on any object of type Object. When you use instance method syntax to call this method, omit the first parameter. For more information, see Extension Methods (Visual Basic) or Extension Methods (C# Programming Guide).
See Also

Reference