Advertisement
Guest User

Untitled

a guest
Nov 20th, 2019
133
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.90 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 p07_siruri_de_caractere
  8. {
  9. class Program
  10. {
  11. static void Main(string[] args)
  12. {
  13. ///String uri
  14.  
  15. ///1.operatori ==, !=, =(atribuire), +(concatenare), +=
  16.  
  17. string s, t;
  18. s = "caseta";
  19. t = "caserola";
  20.  
  21. if (s == t) Console.WriteLine("Egale");
  22. else Console.WriteLine("Diferite");
  23.  
  24. /// if (s < t) Console.WriteLine("s mai mic lexicografic decat t");
  25.  
  26. s += t;
  27. Console.WriteLine(s);
  28.  
  29. //2.Secvente si caractere Verbatim
  30. //Exaemple de secvente escape; \n, \t (tab)
  31. // \a(bip), \r \\ ,\', \"
  32. string cale = "d : \\12A\\csharp\\proiecte";
  33. Console.WriteLine(cale);
  34.  
  35. string w = "Citez: \"Broasca nu oracaie pe uscat\"";
  36. Console.WriteLine(w);
  37.  
  38. // ca sa scap de secventele escape folosesc
  39. // caractere verbatim
  40. string q = @"d:\ana\are\mere";
  41. Console.WriteLine(q);
  42.  
  43.  
  44. string x = @"Popescu
  45. Radu
  46. Alexandru
  47. Gabriel";
  48. Console.WriteLine(x);
  49.  
  50. //3.Indexatori.Proprietate Length
  51.  
  52. //afisare litere cu litere a unui string
  53.  
  54. for (int i = 0; i < s.Length; i++)
  55. Console.Write(s[i]);
  56. Console.WriteLine("\n\n");
  57.  
  58. // afisare de la drepta la stanga
  59. for(int i = s.Length - 1; i >=0 ; i--)
  60. Console.Write(s[i]);
  61. Console.WriteLine("\n\n");
  62.  
  63. //Tipul string nu se initializeaza
  64. // folosind "new" ci prin atribuire
  65.  
  66. //indexatorul tipul strig este Read-Only:
  67. // este eronat sa scriem s[2] = 'A';
  68.  
  69. }
  70. }
  71. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement