public static void Method(Type t, string m) { Console.WriteLine("*** Вызвать метод по параметру ***\n"); MethodInfo mt = t.GetMethod(m); int capacity; string name; PassangerPlane samolot = new PassangerPlane(10, "samolot"); string path = @"/home/andrew/Projects/lab12/lab12/param.txt"; using (StreamReader sr = new StreamReader(path, System.Text.Encoding.Default)) { capacity = Int32.Parse(sr.ReadLine()); name = sr.ReadLine(); } PassangerPlane nowySamolot = new PassangerPlane(capacity, name); PassangerPlane[] ca = new PassangerPlane[1] { nowySamolot }; if ((bool)mt.Invoke(samolot, ca)) { Console.WriteLine("Самолеты равны по вместимости"); } else { Console.WriteLine("Самолеты НЕ равны по вместимости"); } }
public override bool Equals(object obj) { if (obj == null) { return(false); } if (this.GetType() != obj.GetType()) { return(false); } PassangerPlane c = (PassangerPlane)obj; return(c.GetCapacity() == GetCapacity()); }
public static void Main(string[] args) { PassangerPlane plane = new PassangerPlane(100, "Plane_1"); TU134 tU = new TU134(15, 100, "New TU134"); Reflector.All(plane.GetType()); Reflector.ShowAllMethods <PassangerPlane>(plane); Reflector.ShowAllFields <PassangerPlane>(plane); Reflector.ShowAllProperties <PassangerPlane>(plane); Reflector.ShowAllInterfaces <TU134>(tU); string myStr = "12345"; Reflector.FindMethodsByParam(plane.GetType(), myStr.GetType()); Reflector.Method(plane.GetType(), "Equals"); Console.ReadKey(); }