Skip to content
Martijn Bodeman edited this page Mar 16, 2026 · 21 revisions

To convert an Iban type to a string, call the ToString(IbanNet.IbanFormats format) method:

Format Format specifier Example Use case examples
Electronic (default) E NL91ABNA0417164300 Persistence, API's, transactions, electronic messaging, generating QR codes, etc.
Print P NL91 ABNA 0417 1643 00 Privileged users in UI's, generating PDF's (like invoices), etc.
Obfuscated O XXXXXXXXXXXXXXXX4300 Less privileged users in UI's (ie. an account page in view mode), troubleshooting/debugging (like Intellisense)
Hidden (since v6.1.0) H **** Log files, activity feeds, etc.

Example

IIbanParser parser = new IbanParser(new IbanValidator());
Iban iban = parser.Parse("NL91 ABNA 0417 1643 00");
Debug.WriteLine(iban.ToString(IbanFormat.Obfuscated));  // XXXXXXXXXXXXXXXX4300
Debug.WriteLine(iban.ToString(IbanFormat.Hidden));      // ****

You can also use string.Format or string interpolation using the format specifier:

// string.Format:
Debug.WriteLine(string.Format("{0:P}", iban));          // NL91 ABNA 0417 1643 00

// String interpolation:
Debug.WriteLine($"{iban:E}");                           // NL91ABNA0417164300

Personally Identifiable Information (PII)

Because the electronic format is the default format (when not specifying a format explicitly), please be careful what and how you log, especially if you log complete types and the logger supports log destructuring or the type being logged allows deconstruction. Us developers should take PII serious!

Clone this wiki locally