search from type.GetMethod(MethodName) Does the object Method[] methods = c.getMethods(); implement the method? Method methlist[] type.GetMethod(MethodName) Does the = cls.getDeclaredMethods(); respond to the for (int i = 0; i < method? methlist.length; i++) { Method m = methlist[i]; System.out.println("name = " + m.getName()); Method.invoke(..) type.InvokeMember(…) Invoke a method Exception Handling C# and Java support formal and they have many similarities. They use very similar syntax for declaring exceptions; blocks delineate guarded regions, blocks try catch handle exceptions and blocks release any resources. Exceptions can be caught finally and re-thrown. You can either catch specific exceptions or use a catch-all statement. Unlike Java, C# does not have checked exceptions. In Java, checked exceptions are declared the “throws” keyword and that must be handled by calling code. In C#, all exceptions are unchecked and there is no counterpart to the declaration for the throws method signature. try { //block of code } //Most specific: catch (ArgumentNullException e) { Console.WriteLine(“{0}First exception caught.”, e); } specific catch (Exception e) { Console.WriteLine(“{0}First exception caught.”, e); }
search from Method[] methods = c.getMethods(); Does the object implement the method? type.GetMethod(MethodName) Method methlist[] = cls.getDeclaredMethods(); for (int i = 0; i < methlist.length; i++) { Method m = methlist[i]; System.out.println("name = " + m.getName()); Does the respond to the method? type.GetMethod(MethodName) Method.invoke(..) Invoke a method type.InvokeMember(…) Exception Handling C# and Java support formal and they have many similarities. They use very similar syntax for declaring exceptions; try blocks delineate guarded regions, catch blocks handle exceptions and finally blocks release any resources. Exceptions can be caught and re-thrown. You can either catch specific exceptions or use a catch-all statement. Unlike Java, C# does not have checked exceptions. In Java, checked exceptions are declared the “throws” keyword and that must be handled by calling code. In C#, all exceptions are unchecked and there is no counterpart to the throws declaration for the method signature. try { //block of code } //Most specific: catch (ArgumentNullException e) { Console.WriteLine(“{0}First exception caught.”, e); } specific catch (Exception e) { Console.WriteLine(“{0}First exception caught.”, e); }
wp8.docx