-
Notifications
You must be signed in to change notification settings - Fork 33
IbanBuilder
Martijn Bodeman edited this page Dec 31, 2022
·
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 depends 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.
if (registry.TryGetValue("GB", out IbanCountry country))
{
string iban = new IbanBuilder()
.WithCountry(country)
.WithBankIdentifier("NWBK")
.WithBranchIdentifier("601613")
.WithBankAccountNumber("31926819")
.Build();
Console.WriteLine(iban); // GB29NWBK60161331926819
}