Advertisement
Guest User

Untitled

a guest
Jan 28th, 2020
99
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.  
  3. namespace Es_array
  4. {
  5. class Program
  6. {
  7. static void Main(string[] args)
  8. {
  9. /*
  10. s1=lenght: restituisce la lunghezza della stringa come int
  11. contains : verifica se il contenuto di una stringa è presente in un'altra e restituisce un valore booleano (True/False)
  12. indexOf : resituisce un valore in int che indica la posizione nella quale è contenuto tale carattere
  13. compareTo: confronta 2 stringhe e verifica se sono uguali: se sono uguali restuisce valore 0 se sono diverse -1
  14. Substring: restituisce il contenuto della stringa dalla posizione inserita in poi
  15. */
  16. string s1 = "gesù cristo";
  17. string s2 = "ao m";
  18. Console.WriteLine("La lunghezza della stringa è " + s1.Length);
  19. Console.WriteLine(s1.Contains(s2));
  20. Console.WriteLine(s1.IndexOf('c'));
  21. string s3 = "ciao";
  22. string s4 = "ciao";
  23. Console.WriteLine(s3.CompareTo(s4));
  24. string s5 = "pappagallo";
  25. Console.WriteLine(s5.Substring(5));
  26. Console.WriteLine(s5.Substring(5,5));
  27.  
  28.  
  29.  
  30.  
  31. }
  32. }
  33. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement