In the following delegate example, how does the compiler infer what type of variable alpha is?
delegate double Doubler(double x);
public class Test
{
Doubler dbl = (alpha) =>
{
return alpha * 2
};
Console.WriteLine(dbl(10));
Console.WriteLine(dbl(5.5));
}
I found this expression on a website, I think based on the answers, is this wrong?
"In our example, we specified the type of the argument. If you want, you can let the compiler find out the type of the argument. In this case, pass only the name of the argument, not its type. Example:"
source
share