d. private delegate void MyDelegate(float x);
a. You need to use a cast operator to execute the method to which a delegate variable refers.
b. Store a method that returns an Employee in a delegate that represents methods that return a Person.
c. Store a method that takes a Person as a parameter in a delegate that represents methods that take an Employee as a parameter.
b. Methods that take an Order object as a parameter and return void.
a. Methods that take no parameters and return an Order object.
d. F = delegate(float x) { return x * x; };
c. note = () => MessageBox.Show(“Hi”);
d. Both a and c are correct.
b. A statement lambda cannot return a value.
d. Both b and c are correct.
b. Create an OnAddressChanged method in the Employee class that raises the event.
a. myButton.Click += myButton_Click;
c. if (Stopped != null) Stopped(this, args);
c. If an object subscribes to an event once and then unsubscribes twice, its event handler throws an exception when the event is raised.
a. A derived class can raise a base class event by using code similar to the following: if (base.EventName != null) base.EventName(this, args);
a. You can nest a try-catch-finally block inside a try, catch, or finally section.
d. Either b or c.
d. All of the above.
b. If you rethrow the exception ex with the statement throw, the exception’s call stack is reset to start at the current line of code.
c. Make it implement IDisposable.
E1. Which of the following statements creates a delegate type named MyFunc that represents a method that takes a parameter that is an array of decimal values and returns a decimal result?
a. delegate decimal(decimal[] values) MyFunc
b. delegate decimal MyFunc(decimal values[])
c. delegate decimal[] MyFunc(decimal values)
d. delegate decimal MyFunc(decimal[] values)
d. delegate decimal MyFunc(decimal[] values)
E2. If rate is a delegate variable that takes a float parameter and returns a float result, which of the following statements will work assuming x is a float variable?
a. int y = rate(x)
b. float y = rate(x)
c. rate(y, x)
d. double y = rate(x)
b. float y = rate(x)
d. double y = rate(x)
E3. If rate is a delegate variable that refers to the method Rate, then what is the practical difference between calling rate or Rate?
a. You can omit the parameters when calling rate.
b. You must save the result of rate into a variable, but you can use the result of Rate in an expression.
c. You can save Rate in another delegate variable, but you cannot save rate in another delegate variable.
d. There is no practical difference.
d. There is no practical difference.