Table of Contents

Class MongoServerAddress

Namespace
MongoDB.Driver
Assembly
MongoDB.Driver.dll

The address of a MongoDB server.

[Serializable]
public class MongoServerAddress : IEquatable<MongoServerAddress>
Inheritance
MongoServerAddress
Implements
Inherited Members

Constructors

MongoServerAddress(string)

Initializes a new instance of MongoServerAddress.

public MongoServerAddress(string host)

Parameters

host string

The server's host name.

MongoServerAddress(string, int)

Initializes a new instance of MongoServerAddress.

public MongoServerAddress(string host, int port)

Parameters

host string

The server's host name.

port int

The server's port number.

Properties

Host

Gets the server's host name.

public string Host { get; }

Property Value

string

Port

Gets the server's port number.

public int Port { get; }

Property Value

int

Methods

Equals(MongoServerAddress)

Compares two server addresses.

public bool Equals(MongoServerAddress rhs)

Parameters

rhs MongoServerAddress

The other server address.

Returns

bool

True if the two server addresses are equal.

Equals(object)

Compares two server addresses.

public override bool Equals(object obj)

Parameters

obj object

The other server address.

Returns

bool

True if the two server addresses are equal.

GetHashCode()

Gets the hash code for this object.

public override int GetHashCode()

Returns

int

The hash code.

Parse(string)

Parses a string representation of a server address.

public static MongoServerAddress Parse(string value)

Parameters

value string

The string representation of a server address.

Returns

MongoServerAddress

A new instance of MongoServerAddress initialized with values parsed from the string.

ToString()

Returns a string representation of the server address.

public override string ToString()

Returns

string

A string representation of the server address.

TryParse(string, out MongoServerAddress)

Tries to parse a string representation of a server address.

public static bool TryParse(string value, out MongoServerAddress address)

Parameters

value string

The string representation of a server address.

address MongoServerAddress

The server address (set to null if TryParse fails).

Returns

bool

True if the string is parsed succesfully.

Operators

operator ==(MongoServerAddress, MongoServerAddress)

Compares two server addresses.

public static bool operator ==(MongoServerAddress lhs, MongoServerAddress rhs)

Parameters

lhs MongoServerAddress

The first address.

rhs MongoServerAddress

The other address.

Returns

bool

True if the two addresses are equal (or both are null).

operator !=(MongoServerAddress, MongoServerAddress)

Compares two server addresses.

public static bool operator !=(MongoServerAddress lhs, MongoServerAddress rhs)

Parameters

lhs MongoServerAddress

The first address.

rhs MongoServerAddress

The other address.

Returns

bool

True if the two addresses are not equal (or one is null and the other is not).