https://github.com/belidzs/hungarianbankaccount
This library written in pure C# checks the validity of a Hungarian bank account number and determines which bank is belongs to.
https://github.com/belidzs/hungarianbankaccount
bank-account bankaccount banking central-bank giro hungarian mnb
Last synced: 4 months ago
JSON representation
This library written in pure C# checks the validity of a Hungarian bank account number and determines which bank is belongs to.
- Host: GitHub
- URL: https://github.com/belidzs/hungarianbankaccount
- Owner: belidzs
- License: mit
- Created: 2019-05-25T13:45:53.000Z (over 6 years ago)
- Default Branch: develop
- Last Pushed: 2020-02-15T00:16:37.000Z (over 5 years ago)
- Last Synced: 2025-07-17T13:21:16.132Z (4 months ago)
- Topics: bank-account, bankaccount, banking, central-bank, giro, hungarian, mnb
- Language: C#
- Homepage: https://www.nuget.org/packages/HungarianBankAccount/
- Size: 45.9 KB
- Stars: 0
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# HungarianBankAccount
This library written in C# checks the validity of a Hungarian bank account number (in GIRO format) and determines which bank it belongs to.
## Usage
Let's check a valid bank account:
```csharp
string validAccountNumber = "10032000-01076349";
var accountValid = new BankAccount(validAccountNumber);
System.Console.WriteLine($"{accountValid.AccountNumber}: IsValid = {accountValid.IsValid}, Bank = {accountValid.Bank}");
```
An invalid bank account will return `IsValid = false` and throws `FormatException` when `Bank` property is read:
```csharp
var accountInvalidNumber = new BankAccount("00000000-00000000-00000001");
System.Console.WriteLine($"{accountInvalidNumber.AccountNumber}: IsValid = {accountInvalidNumber.IsValid}");
try
{
System.Console.WriteLine($"Checking bank details for {accountInvalidNumber.AccountNumber}");
System.Console.WriteLine(accountInvalidNumber.Bank);
}
catch (FormatException)
{
System.Console.WriteLine($"{typeof(FormatException)} was thrown because account number was not valid");
}
```
When the syntax of the bank account number is correct, but it doesn't belong to any known bank `KeyNotFoundException` is thrown:
```csharp
var accountInvalidBank = new BankAccount("00000000-00000000");
System.Console.WriteLine($"{accountInvalidBank.AccountNumber}: IsValid = {accountInvalidBank.IsValid} (it's technically valid)");
try
{
System.Console.WriteLine($"Checking bank details for {accountInvalidBank.AccountNumber}");
System.Console.WriteLine(accountInvalidBank.Bank);
}
catch (KeyNotFoundException)
{
System.Console.WriteLine($"{typeof(KeyNotFoundException)} was thrown, because the bank account number doesn't belong to any known bank.");
}
```
Alternatively you can use the static `Validator.Validate(string accountNumber)` method to check if the number is syntactically and mathematically correct.
## Download from Nuget
[](https://www.nuget.org/packages/HungarianBankAccount/)