-
Notifications
You must be signed in to change notification settings - Fork 35
IbanBuilder
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:
- Start by getting the country specific information from the
IIbanRegistry. - Then, using the builder, supply all the information and invoke
.Build().
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); // GB29NWBK60161331926819Note: you may want to consider handling the
BankAccountBuilderExceptionwhich may occur when calling the.Build()method.
