xxxxxxxxxxxxxxxxx

by shpendzzzzrrrzzzz on March 19th, 2012
No notes
Syntax: C#
Show lines - Hide lines - Show in textbox - Download
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5.  
  6. namespace augusti2011
  7. {
  8. public class Uppgift1
  9. {
  10. private string name = "tenta";
  11. static void a()
  12. {
  13. Person p = new Person("1", "anna");
  14. p.print();
  15. }
  16. static void b()
  17. {
  18. Person p1 = new Person("1", "data");
  19. new Uppgift1().bTemp(p1);
  20. p1.print();
  21. }
  22. void bTemp(object imi)
  23. {
  24. Person p = imi as Person;
  25. p.Name = "Hata " + this;
  26. }
  27. static void c()
  28. {
  29. A a;
  30. Person p1 = new Person("1342", "anna");
  31. a = p1;
  32. p1 = a as Person;
  33. Console.WriteLine(f(new Person(), new Person()));
  34. }
  35. static bool f(object a, object b)
  36. {
  37. return (a.GetType() == b.GetType());
  38. }
  39. static void d()
  40. {
  41. Temp.MyDelegate d = new Temp.MyDelegate(f);
  42. Person p1 = new Person("1342", "anna");
  43. IMyInterface imi = p1;
  44. bool b = d(new Person(), imi);
  45. Console.WriteLine(b.GetType());
  46. }
  47. static void e()
  48. {
  49. Person p1 = new Person("1342", "anna");
  50. Person p2 = new Person("1562", "fatso");
  51. p2 = p1;
  52. Console.WriteLine(p1 == p2);
  53. }
  54.  
  55. static void Main(string[] args)
  56. {
  57. a();
  58. b();
  59. c();
  60. d();
  61. e();
  62. }
  63.  
  64. }
  65. }
  66.  
  67.  
  68. using System;
  69. using System.Collections.Generic;
  70. using System.Linq;
  71. using System.Text;
  72.  
  73. namespace augusti2011
  74. {
  75. class A
  76. {
  77. public void print()
  78. {
  79. base.print();
  80. Console.WriteLine("Hej A");
  81. }
  82. }
  83. }
  84.  
  85.  
  86. using System;
  87. using System.Collections.Generic;
  88. using System.Linq;
  89. using System.Text;
  90.  
  91. namespace augusti2011
  92. {
  93. interface IMyInterface
  94. {
  95. object f(string str);
  96. }
  97. }
  98.  
  99. using System;
  100. using System.Collections.Generic;
  101. using System.Linq;
  102. using System.Text;
  103.  
  104. namespace augusti2011
  105. {
  106. class Person : A, IMyInterface
  107. {
  108. private string id;
  109. private string name;
  110. public Person() { }
  111. public Person(string id, string name)
  112. {
  113. Name = name;
  114. this.id = id;
  115. }
  116.  
  117. public string Name { get { return name; } set { name = value; } }
  118. public new void print()
  119. {
  120. base.print();
  121. Console.WriteLine(Name);
  122. }
  123. public object f(string str)
  124. {
  125. return str.GetType();
  126. }
  127. }
  128. }
  129.  
  130.  
  131. using System;
  132. using System.Collections.Generic;
  133. using System.Linq;
  134. using System.Text;
  135.  
  136. namespace augusti2011
  137. {
  138. class Temp
  139. {
  140. public delegate bool MyDelegate(object x, object y);
  141. }
  142. }
  143.  

Leave a Reply

Note: XHTML is allowed. Your email address will never be published.

Subscribe to this comment feed via RSS