Exam 70-536 : .NET Framework Application Development Foundation Part – 15
Question: You write the following code to implement the CompanyClass.MyMethod function.
1 2 3 4 5 6 7 |
public class CompanyClass { public int MyMethod(int arg) { return arg; } } |
You need to call the CompanyClass.MyMethod function dynamically from an unrelated class in your assembly. Which code segment should you use?
1 2 3 4 |
CompanyClass myClass = new CompanyClass(); Type t = typeof(CompanyClass); MethodInfo m = t.GetMethod("MyMethod"); int i = (int)m.Invoke(this, new object[] { 1 }); |
1 2 3 4 |
CompanyClass myClass = new CompanyClass(); Type t = typeof(CompanyClass); MethodInfo m = t.GetMethod("MyMethod"); int i = (int) m.Invoke(myClass, new object[] { 1 }); |
1 2 3 4 |
CompanyClass myClass = new CompanyClass(); Type t = typeof(CompanyClass); MethodInfo m = t.GetMethod("CompanyClass.MyMethod"); int i = (int)m.Invoke(myClass, new object[] { 1 }); |
1 2 3 |
Type t = Type.GetType("CompanyClass"); MethodInfo m = t.GetMethod("MyMethod"); int i = (int)m.Invoke(this, new object[] { 1 }); |
Correct Answer: 2 Question: You are developing an application for a client residing in Hong Kong. You need to display negative currency values by using a minus sign. Which code segment should you use?
1 2 3 |
NumberFormatInfo culture = new CultureInfo("zh-HK").NumberFormat; culture.NumberNegativePattern = 1; return numberToPrint.ToString("C", culture); |
1 2 3 |
NumberFormatInfo culture = new CultureInfo("zh-HK").NumberFormat; culture.CurrencyNegativePattern = 1; return numberToPrint.ToString("C", culture); |
1 2 |
CultureInfo culture = new CultureInfo("zh-HK"); return numberToPrint.ToString("-(0)", culture); |
1 2 |
CultureInfo culture = new CultureInfo("zh-HK"); return numberToPrint.ToString("()", culture); |
Correct Answer: 2 Question: You are writing a method that accepts a string parameter named message. Your method must break the message parameter into individual … Click here to continue…..