Programming in C# — Question 87
You are developing an application.
You need to declare a delegate for a method that accepts a string as a parameter, and then returns a string.
Which type of delegate should you use?
Answer options
- A. Func<string, string>
- B. Action< string, string>
- C. Func< string>
- D. Action< string>
Correct answer: A
Explanation
The correct choice is A, Func<string, string>, because it is specifically designed for methods that take one string argument and return a string. Option B, Action<string, string>, is incorrect because Action does not return a value. Options C and D also do not meet the requirement since they either don't take any parameters or only take a single string parameter without returning a value.