Skip to content
Martijn Bodeman edited this page May 20, 2023 · 9 revisions

The IbanBuilder can be used to infer an IBAN from bank, branch and account number information. The IBAN that is generated will have a valid check digit to pass validation.

The information needed to generate a valid IBAN differs per country. Some countries may require that you have the bank, branch and account number information, where others may only require the bank and account number information.

To infer an IBAN:

  1. Start by getting the country specific information from the IIbanRegistry.
  2. Then, using the builder, supply all the information and invoke .Build().

Example

IIbanRegistry registry = IbanRegistry.Default; // Or use IIbanRegistry from a DI container.

string iban = new IbanBuilder()
    .WithCountry("GB", registry)
    .WithBankIdentifier("NWBK")
    .WithBranchIdentifier("601613")
    .WithBankAccountNumber("31926819")
    .Build();

Console.WriteLine(iban); // GB29NWBK60161331926819

Note: you may want to consider handling the BankAccountBuilderException which may occur when calling the .Build() method.