Advertisement
ostyleo

Untitled

Jan 21st, 2018
92
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 2.37 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. // RASPUNS: 100 200 :)
  8. //namespace PregatireExamen {
  9. //    class Swaping {
  10. //        public void swap(ref int x, ref int y) {
  11. //            int a, b; a = x; b = y; swap2(ref a, ref b);
  12. //        }
  13. //        public void swap2(ref int a, ref int b) {
  14. //            int temp; temp = a; a = b; b = temp;
  15. //        }
  16. //        static void Main(string[] args) {
  17. //            Swaping n = new Swaping();
  18. //            int a = 100;
  19. //            int b = 200;
  20. //            n.swap(ref a, ref b);
  21. //            Console.WriteLine(a + " " + b);
  22. //        }
  23. //    }
  24. //}
  25.  
  26. //--------------------------------------------CURS 10-11 Sem 12--------------------------------------------//
  27.  
  28. // RASPUNS: 2, 123, bravo, 1 (exista si destructor pt B... se afiseaza "123"[0] = 1) (cand se cere abc se trimite cab-ul)
  29. //namespace Ex1 {
  30. //    public interface A {
  31. //        string abc { get; set; }
  32. //    }
  33. //    public class B : A {
  34. //        string cab;
  35. //        public string abc { get => cab; set => cab = value; }
  36. //        public B() {
  37. //            cab = "123";
  38. //        }
  39. //        public A A() {
  40. //            Console.WriteLine(cab);
  41. //            return (A)this;
  42. //        }
  43. //        ~B() {
  44. //            Console.WriteLine(cab[0].ToString());
  45. //        }
  46. //    }
  47. //    public class C : B {
  48. //        public C() {
  49. //            Console.WriteLine(this.abc[1].ToString());
  50. //        }
  51. //    }
  52. //    public class Exercitiu1 {
  53. //        static void Main(string[] args) {
  54. //            var c = new C();
  55. //            var ainB = c.A();
  56. //            Console.WriteLine("bravo");
  57. //        }
  58. //    }
  59. //}
  60.  
  61. // RASPUNS: 10 (a.Add nu face nimic)
  62. //namespace Ex2 {
  63. //    public class A {
  64. //        public int nr { get; set; }
  65. //        public A(int a) {
  66. //            nr = a + 3;
  67. //        }
  68. //        public void Increment() {
  69. //            nr++;
  70. //        }
  71. //        public void Add(int a) {
  72. //            a += a;
  73. //        }
  74. //        public override string ToString() {
  75. //            return (nr + 1).ToString();
  76. //        }
  77. //    }
  78. //    public class Exercitiul2 {
  79. //        static void Main(string[] args) {
  80. //            var a = new A(5);
  81. //            a.Increment();
  82. //            a.Add(3);
  83. //            Console.WriteLine(a);
  84. //        }
  85. //    }
  86. //}
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement