Struct SepaBIC
Helper class for working with SWIFT Addresses.
public struct SepaBIC
- Inherited Members
Constructors
SepaBIC(string)
Wraps a BIC string within a SepaBIC.
public SepaBIC(string sBIC)
Parameters
sBIC
stringThe BIC to be wrapped. If this parameter is
null
or an empty string, then this will be a NullBIC. Use Capture(string) in order to pre-process a user entered BIC.
Exceptions
- ArgumentException
The given BIC string was not a syntactically correct BIC (i.e. IsValid(string) returns
false
on it.
Fields
MAXLENGTH
The maximum length of a valid BIC.
public const int MAXLENGTH = 11
Field Value
MINLENGTH
The minimum length of a valid BIC.
public const int MINLENGTH = 8
Field Value
NullBIC
Represents an unset SepaBIC instance.
public static readonly SepaBIC NullBIC
Field Value
Properties
BIC
Provides the wrapped BIC string. The value is
null
if this BIC IsNull.
public string BIC { get; }
Property Value
BIC11
Provides the BIC with always 11 characters.
public string BIC11 { get; }
Property Value
- string
If the BIC does not already consist of 11 characters, then it is padded with 'X' character before it is returned. If this is the NullBIC, then
null
is returned.
CountryCode
Provides the country code portion of this BIC.
public string CountryCode { get; }
Property Value
IsNull
Indicates whether this BIC is the NullBIC.
public bool IsNull { get; }
Property Value
ShortBIC
If the BIC consists of 11 characters and ends with XXX, then this returns only the first 8 characters of the BIC. Otherwise the full BIC is returned.
public string ShortBIC { get; }
Property Value
TerminalCode
If this BIC was extracted from a SWIFT adress, then this is the Terminal Code character from it. The field BIC always excludes the Terminal Code.
public char TerminalCode { get; }
Property Value
Methods
Capture(string)
Captures a BIC entered by the user, removing whitespace and converting lower case to upper case.
public static string Capture(string sBIC)
Parameters
sBIC
string
Returns
- string
If the parameter sBIC was
null
or an empty string, or contains only whitespace, then the return value will benull
.
Remarks
Any non alphanumeric characters, such as whitespace or symbols, are removed from the captured BIC.
Any lower case letters are converted into upper case letters.
IsValid(string)Equals(object)
Compares the BIC11 value for equivalence.
public override bool Equals(object obj)
Parameters
obj
objectRight hand side to compare to.
Returns
GetCountryCode(string)
Returns the country code from a BIC.
public static string GetCountryCode(string sBIC)
Parameters
sBIC
stringValid BIC from which the country code shall be extracted.
Returns
- string
If the given BIC was
null
, or an empty string, or an invalid BIC, thennull
is returned. Otherwise the 2-character country code extracted from the BIC is returned.
GetHashCode()
Provides an hash code based on the BIC11.
public override int GetHashCode()
Returns
- int
Hashcode.
IsValid(string)
Checks whether a given BIC is valid.
public static bool IsValid(string sBIC)
Parameters
sBIC
stringString that shall be checked for a BIC. May be
null
.
Returns
- bool
If the parameter was
null
, or an empty string, thenfalse
is returned. If the given string does not validate as a probable BIC, thenfalse
is returned, otherwise,true
is returned.
IsValidStrict(string)
Checks whether this is a BIC that is strictly valid for international bank transfers.
public static bool IsValidStrict(string sBIC)
Parameters
sBIC
string
Returns
Remarks
This method applies additional checks over IsValid(string) in order to reject testing codes and other sematic checks.
ParseAddress(string)
Parses a BIC from a 12 character SWIFT sddress.
public static SepaBIC ParseAddress(string sSwiftAddress)
Parameters
sSwiftAddress
stringThe 12 character SWIFT address.
Returns
Exceptions
- ArgumentNullException
The parameter sSwiftAddress was
null
.- ArgumentException
The sSwiftAddress string was not a valid SWIFT address.
ToString()
Returns the complete SWIFT address.
public override string ToString()
Returns
- string
If this SepaBIC was constructed through ParseAddress(string), then the returned string includes the TerminalCode in its 9th position. Otherwise the return value is just the BIC. If this SepaBIC is actually null, then this methode returns an empty string.
TryCapture(string)
Tries to Capture(string) a BIC. If no valid BIC was captured, then NullBIC is returned.
public static SepaBIC TryCapture(string sPaperBIC)
Parameters
sPaperBIC
string
Returns
Operators
operator ==(SepaBIC, SepaBIC)
Equality operator compares the BIC11 values.
public static bool operator ==(SepaBIC lhs, SepaBIC rhs)
Parameters
Returns
operator !=(SepaBIC, SepaBIC)
Inequality operator compares the BIC11 values.
public static bool operator !=(SepaBIC lhs, SepaBIC rhs)