public static string ToIbanFormat(this string value)
{
if (value.Length > 16)
{
string iban = value.Substring(0, 4) + " " +
value.Substring(4, 4) + " " +
value.Substring(8, 4) + " " +
value.Substring(12, 4) + " " +
value.Substring(16);
return iban;
}
return value;
}
can I somehow do it dynamically if there is more characters that I can use spaces also after each 4 char.
For example my code will not work for: GR16 0110 1250 0000 0001 2300 695
and I do n't want to add another if. Can I do this dynamically to check the length and then substring it?