Struct SepaIBAN
Helper class for working with IBANs.
Inherited Members
Namespace: Subsembly.Sepa
Assembly: Subsembly.Sepa.dll
Syntax
public struct SepaIBAN : IComparable<SepaIBAN>, IComparable
Constructors
SepaIBAN(String)
Wrap an IBAN given in its electronic format with a new SepaIBAN instance.
Declaration
public SepaIBAN(string sIBAN)
Parameters
Type | Name | Description |
---|---|---|
System.String | sIBAN | Complete IBAN that shall be wrapped by the new SepaIBAN instance. The IBAN must
be given in its electronic format, i.e. it must not contain whitespace or symbol
characters, and all letters must be upper case. If this parameter is |
Remarks
This constructor does not validate the given IBAN checksum, but it validates whether the given string looks like an IBAN using IsValid(String).
Exceptions
Type | Condition |
---|---|
System.ArgumentException | The given IBAN string was no IBAN in its eletronic format (i.e.
IsValid(String) returns |
SepaIBAN(String, String, String)
Makes a new SepaIBAN by coercing the given parameters with a valid checksum.
Declaration
public SepaIBAN(string sCountryCode, string sBankCode, string sAcctNo)
Parameters
Type | Name | Description |
---|---|---|
System.String | sCountryCode | The two letter country code of the country for which to generate the IBAN. This is not validated to be a real country code, and thus may be any string consisting of two upper case letters. |
System.String | sBankCode | Optional bank code portion of the IBAN to be made, including any leading
zeroes. May be |
System.String | sAcctNo | The complete account number portion of the IBAN to be made, including any leading
zeroes. This must not be |
Exceptions
Type | Condition |
---|---|
System.ArgumentNullException | The parameter sCountryCode or sAcctNo was |
System.ArgumentException | The sCountryCode did not consist of two upper case characters, or, the sBankCode (if present) or sAcctNo did not consist solely of upper case characters and digits. Or the combined length did exceed the 34 character IBAN limit. |
Fields
MAXLENGTH
The maximum length of any IBAN in electronic format without IBAN prefix and without any symbols or whitespace is 34.
Declaration
public const int MAXLENGTH = 34
Field Value
Type | Description |
---|---|
System.Int32 |
MINLENGTH
The minimum length of any IBAN in electronic format without IBAN prefix and without any symbols or whitespace is 6.
Declaration
public const int MINLENGTH = 6
Field Value
Type | Description |
---|---|
System.Int32 |
NullIBAN
Represents an unset SepaIBAN instance.
Declaration
public static readonly SepaIBAN NullIBAN
Field Value
Type | Description |
---|---|
SepaIBAN |
Properties
AcctNo
Provides the branch and account number part of this IBAN, less any leading zeroes.
Declaration
public readonly string AcctNo { get; }
Property Value
Type | Description |
---|---|
System.String |
Remarks
May be null
, if it cannot be determined, because the IBAN structure is not
known.
BankCode
Provides the bank identification code part of this IBAN, less any leading zeroes.
Declaration
public readonly string BankCode { get; }
Property Value
Type | Description |
---|---|
System.String |
Remarks
May be null
, if it cannot be determined, because the IBAN structure is not
known.
CountryCode
Provides the country code portion of this IBAN.
Declaration
public readonly string CountryCode { get; }
Property Value
Type | Description |
---|---|
System.String |
IBAN
Provides the wrapped IBAN in its electronic format. The value is
null
if this IBAN IsNull.
Declaration
public readonly string IBAN { get; }
Property Value
Type | Description |
---|---|
System.String |
IsNull
Indicates whether this IBAN is the NullIBAN.
Declaration
public readonly bool IsNull { get; }
Property Value
Type | Description |
---|---|
System.Boolean |
Length
Returns the actual length of this IBAN. If this IsNull, then zero is returned.
Declaration
public readonly int Length { get; }
Property Value
Type | Description |
---|---|
System.Int32 |
Methods
Capture(String)
Creates the electronic format IBAN representation from a given paper format IBAN.
Declaration
public static string Capture(string sPaperIBAN)
Parameters
Type | Name | Description |
---|---|---|
System.String | sPaperIBAN | Paper format IBAN to be captured in electronic format. This may be prefixed with IBAN and may contain any number of blanks. |
Returns
Type | Description |
---|---|
System.String | Electronic format IBAN without blanks and without optional IBAN prefix. Any lower case characters have been converted to upper case. The result was not validated as an IBAN. It is up to the caller to validate the IBAN using IsValid(String) or other methods. The result may even be an empty string! If the parameter sPaperIBAN was |
Remarks
If the given paper IBAN starts with the prefix "IBAN", then this prefix is removed from the captured electronic IBAN.
Any non alphanumeric characters, such as whitespace or symbols, are removed from the captured electronic IBAN.
Any lower case letters are converted into upper case letters.
If the
IsValid(String)CompareTo(SepaIBAN)
Declaration
public int CompareTo(SepaIBAN aOtherIBAN)
Parameters
Type | Name | Description |
---|---|---|
SepaIBAN | aOtherIBAN |
Returns
Type | Description |
---|---|
System.Int32 |
CompareTo(Object)
Declaration
public int CompareTo(object aObject)
Parameters
Type | Name | Description |
---|---|---|
System.Object | aObject |
Returns
Type | Description |
---|---|
System.Int32 |
Equals(Object)
Compares the electronic IBAN representation for equivalence.
Declaration
public override bool Equals(object obj)
Parameters
Type | Name | Description |
---|---|---|
System.Object | obj | Right hand side to compare to. |
Returns
Type | Description |
---|---|
System.Boolean | True if both are essentially the same IBAN. |
Overrides
Format()
Formats this electronic format IBAN into a paper format IBAN.
Declaration
public string Format()
Returns
Type | Description |
---|---|
System.String | Paper format IBAN. If this method is applied to the NullIBAN, then an empty string is returned. |
Remarks
The paper representation of the IBAN is the same as the electronic format except that the IBAN is split up in groups of 4 characters separated by a space. The last group is variable in length, up to 4 characters.
Capture(String)Format(String)
Nicely formats the given IBAN input into groups of four IBAN characters.
Declaration
public static string Format(string sIBAN)
Parameters
Type | Name | Description |
---|---|---|
System.String | sIBAN |
Returns
Type | Description |
---|---|
System.String |
GetCountryCode(String)
Returns the country code portion of the given IBAN.
Declaration
public static string GetCountryCode(string sIBAN)
Parameters
Type | Name | Description |
---|---|---|
System.String | sIBAN | Complete IBAN to extract the country code from. The IBAN must be given in its
electronic format, i.e. it must not contain whitespace or symbol characters, and
all letters must be upper case. Use Capture(String) in order to pre-process
a paper format IBAN. This parameter may be |
Returns
Type | Description |
---|---|
System.String | If the parameter was |
GetGermanAcctNo(String)
Extract the german account number from an IBAN.
Declaration
public static string GetGermanAcctNo(string sIBAN)
Parameters
Type | Name | Description |
---|---|---|
System.String | sIBAN |
Returns
Type | Description |
---|---|
System.String | The german account number for a valid german IBAN or |
See Also
GetGermanBankCode(String)
Extract the german bank code (Bankleitzahl) from an IBAN.
Declaration
public static string GetGermanBankCode(string sIBAN)
Parameters
Type | Name | Description |
---|---|---|
System.String | sIBAN |
Returns
Type | Description |
---|---|
System.String | The german bankcode for a valid german IBAN or |
See Also
GetHashCode()
Provides an hash code based on the electronic IBAN representation of this IBAN.
Declaration
public override int GetHashCode()
Returns
Type | Description |
---|---|
System.Int32 | Hashcode. |
Overrides
IsValid(String)
Tests whether a string is a valid IBAN in its electronic format.
Declaration
public static bool IsValid(string sIBAN)
Parameters
Type | Name | Description |
---|---|---|
System.String | sIBAN | Complete IBAN to be checked. The IBAN must be given in its electronic format, i.e. it must not contain whitespace or symbol characters, and all letters must be upper case. This parameter must not be null. Use Capture(String) in order to pre-process a paper format IBAN. |
Returns
Type | Description |
---|---|
System.Boolean | If the given string is a valid IBAN, then |
Remarks
The test first checks the string length (must be within MINLENGTH and MAXLENGTH), and whether the string consists solely of upper case alphanumeric characters. Then it checks whether the string starts with a two letter country code, followed by the two digits checksum. Also the checksum itself is verified. Finally it checks the length using all well known SepaIBANSpecs.
Capture(String)ToString()
Returns the electronic format of this IBAN.
Declaration
public override string ToString()
Returns
Type | Description |
---|---|
System.String | Electronic format of this IBAN. |
Overrides
TryCapture(String)
Tries to Capture(String) an IBAN. If no valid IBAN was captured, then NullIBAN is returned.
Declaration
public static SepaIBAN TryCapture(string sPaperIBAN)
Parameters
Type | Name | Description |
---|---|---|
System.String | sPaperIBAN |
Returns
Type | Description |
---|---|
SepaIBAN |
Operators
Equality(SepaIBAN, SepaIBAN)
Equality operator compares the electronic format of the IBAN.
Declaration
public static bool operator ==(SepaIBAN lhs, SepaIBAN rhs)
Parameters
Type | Name | Description |
---|---|---|
SepaIBAN | lhs | |
SepaIBAN | rhs |
Returns
Type | Description |
---|---|
System.Boolean |
Inequality(SepaIBAN, SepaIBAN)
Inequality operator compares the electronic format of the IBAN.
Declaration
public static bool operator !=(SepaIBAN lhs, SepaIBAN rhs)
Parameters
Type | Name | Description |
---|---|---|
SepaIBAN | lhs | |
SepaIBAN | rhs |
Returns
Type | Description |
---|---|
System.Boolean |