Npgsql Api Docs |

# BitString.ToString Method (String)

Returns a string representation of the BitString.

[Visual Basic]
Overloads Public Function ToString( _
ByVal format As String _
) As String
[C#]
public string ToString(
string format
);

#### Parameters

format
  A string which can contain a letter and optionally a number which sets a minimum size for the string returned. In each case using the lower-case form of the letter will result in a lower-case string being returned.

  B | A string of 1s and 0s.
  X | An hexadecimal string (will result in an error unless the string's length is divisible by 4).
  G | A string of 1s and 0s in single-quotes preceded by 'B' (Postgres bit string literal syntax).

  C The format produced by format-string "Y" if legal, otherwise that produced by format-string "G".E The most compact safe representation for Postgres. If single bit will be either a 0 or a 1. Otherwise if it can be that produce by format string "Y" it will, otherwise if there are less than 9bits in length it will be that produced by format-string "G". For longer strings that cannot be represented in hexadecimal it will be a string representing the first part of the string in format "Y" followed by the PostgreSQL concatenation operator, followed by the final bits in the format "G". E.g. "X'13DCE'||B'110'" If format is empty or null, it is treated as if "B" had been passed (the default repreesentation, and that generally used by PostgreSQL for display).

#### Return Value

The formatted string.

#### See Also

BitString Class | NpgsqlTypes Namespace | BitString.ToString Overload List