How can I format this String : 12345678x for this: 12.345.678-X?
I tried to use String.Format
but I could not.
Resolved:
public string RgFormat(object rg)
{
string strRg = rg.ToString();
return strRg.Substring(0, 2) + "." + strRg.Substring(2, 3) + "." + strRg.Substring(5, 3) + "-" + strRg.Substring(8, 1).ToUpper();
}
public string CpfFormat(object cpf)
{
string strCpf = cpf.ToString();
return strCpf.Substring(0, 3) + "." + strCpf.Substring(3, 3) + "." + strCpf.Substring(6, 3) + "-" + strCpf.Substring(9, 2).ToUpper();
}