Advertisement
Guest User

Untitled

a guest
Jun 24th, 2017
57
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.25 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5.  
  6. namespace ConsoleValidacion
  7. {
  8. class Program
  9. {
  10. static void Main(string[] args)
  11. {
  12. //Yo lo veria haciendo una funcion que remplace el valor en la cadena.
  13. string CadenaValidacion = $"Success\nTony Simoes\n(1)\nMS-9-9-2-00-000-0-1\nXamarinDiplomado3.0-Lab11";
  14. string resultado = Incrementa(CadenaValidacion);
  15.  
  16. Console.WriteLine(resultado);
  17. Console.ReadKey();
  18. }
  19.  
  20. //La cadena de texto que ves al final viene de los servidores en internet y se te dice que solo debes hacer una peticion.
  21.  
  22. static string Incrementa (string resultado)
  23. {
  24. char numeroUno = resultado.First(x => x == '1');
  25.  
  26. List<char> test = resultado.ToList();
  27.  
  28. for (int i = 0; i < test.Count; i++)
  29. {
  30. if (test[i] == numeroUno)
  31. {
  32. test[i] = '2';
  33. break;
  34. }
  35. }
  36. StringBuilder str = new StringBuilder();
  37. foreach (var item in test)
  38. {
  39. str.Append(item);
  40. }
  41.  
  42. return str.ToString();
  43. }
  44. }
  45. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement