NOTE: I need only the output. Please give both the answers. Thanks for your help. 8. Read the following code snippet: pu
Posted: Fri Jul 01, 2022 5:34 am
NOTE: I need only the output. Please give both theanswers. Thanks for your help.
8. Read the following code snippet:
public static double Double(double value) { return 2 *value;
}
public static double Square(double value) { return value *value;
}
public static void Test() { List<Func<double,double>> list =
new List<Func<double, double>>() { Double, Square };Process(list, 16);
}
private static voidProcess(List<Func<double,double>> funcs, double value){
double result;
foreach(var action in funcs) { result = action(value);Console.Write(
$"{action.Method.Name}({value}) = {result}. ");
}
}
The output will be:
8. Read the following code snippet:
public static double Double(double value) { return 2 *value;
}
public static double Square(double value) { return value *value;
}
public static void Test() { List<Func<double,double>> list =
new List<Func<double, double>>() { Double, Square };Process(list, 16);
}
private static voidProcess(List<Func<double,double>> funcs, double value){
double result;
foreach(var action in funcs) { result = action(value);Console.Write(
$"{action.Method.Name}({value}) = {result}. ");
}
}
The output will be: