fork(1) download
  1. using static System.Console;
  2.  
  3. public class Program {
  4. public static void Main() {
  5. WriteLine(FormataRG("12345678x"));
  6. WriteLine(FormataRG("123456789"));
  7. }
  8. public static string FormataRG(string texto) => texto.Substring(0, 2) + "." + texto.Substring(2, 3) + "." + texto.Substring(5, 3) + "-" + texto.Substring(8, 1).ToUpper();
  9. }
  10.  
  11. //https://pt.stackoverflow.com/q/55017/101
Success #stdin #stdout 0.02s 15888KB
stdin
Standard input is empty
stdout
12.345.678-X
12.345.678-9