fork download
  1. using static System.Console;
  2.  
  3. public class Test {
  4. public static void Main() {
  5. WriteLine(FormatarCpf("12345678901"));
  6. WriteLine(FormatarCpf("00123456789"));
  7. }
  8. static string FormatarCpf(string cpf) {
  9. return cpf.Substring(0, 3) + "." + cpf.Substring(3, 3) + "." + cpf.Substring(6, 3) + "-" + cpf.Substring(9, 2);
  10. }
  11. }
  12.  
  13. //https://pt.stackoverflow.com/q/75498/101
Success #stdin #stdout 0.02s 24260KB
stdin
Standard input is empty
stdout
123.456.789-01
001.234.567-89