Advertisement
Guest User

Untitled

a guest
Feb 17th, 2020
98
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.79 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Threading.Tasks;
  6.  
  7. namespace ConsoleApplication1
  8. {
  9. class Program
  10. {
  11. static void Main(string[] args)
  12. {
  13. string x = "O rato roeu a rolha...";
  14. string y = "...da garrafa do rei da Rússia";
  15.  
  16. Console.WriteLine("A string x tem {0} carateres", x.Length);
  17.  
  18. if (x.Contains("rolha")) {
  19. Console.WriteLine("A string x contém a palavra \"rolha\"");
  20. }
  21.  
  22. Console.WriteLine("A palavra roeu começa no índice {0}", x.IndexOf("roeu"));
  23. Console.WriteLine("Indice da última ocorrência do carater 'i': {0}", y.LastIndexOf('i'));
  24.  
  25. string x2 = "Análise da frase: \"\"";
  26. x2 = x2.Insert(19, x);
  27. Console.WriteLine("String x2: {0}", x2);
  28.  
  29. string z = "O rato roeu a rolha...";
  30. z = z.Replace(' ', '_');
  31. Console.WriteLine("String z: {0}", z);
  32.  
  33. Console.WriteLine("String y em maiúsculas: {0}", y.ToUpper());
  34.  
  35. x = x.ToUpper();
  36. Console.WriteLine("String x em maiúsculas: {0}", x);
  37.  
  38. Console.WriteLine("Primeiro carater da string x: {0}", x.Substring(0, 1));
  39. Console.WriteLine("Ultimo carater da string x: {0}", x.Substring(x.Length - 1));
  40. Console.WriteLine("Todos os carateres da string y exceto o primeiro: {0}", y.Substring(1));
  41. Console.WriteLine("4º carater da string y: {0}", y.Substring(3, 1));
  42. Console.WriteLine("3 primeiros carateres da string x: {0}", x.Substring(0, 3));
  43. Console.WriteLine("3 últimos carateres da string x: {0}", x.Substring(x.Lenght - 3));
  44.  
  45. Console.ReadKey();
  46. }
  47. }
  48. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement