In the following delegate example, how does the compiler infer what type the variable alpha is?
delegate double Doubler(double x);
public class Test
{
Doubler dbl = (alpha) => //How does it determine what type is alpha?
{
return alpha * 2
};
Console.WriteLine(dbl(10)); //Is it when the method is called? int here;
Console.WriteLine(dbl(5.5)); //double here???
}
I found this statement on a website, I guess based on the responses, is it incorrect?
"In our example, we specified the type of the argument. If you want, you can let the compiler figure out the type of argument. In this case, pass only the name of the argument and not its type. Here is an example:"