You do not know the proper definition of that operator.
The syntax: boolean_expression ? expression1 : expression2
Expression is any operation which returns a value. Void is not a value. Void specifies that no value is returned. If your get this message, at least one of your methods, must return void value. What is more you must in that context assign the value returned by the "?:" operator.
Proper usage of that operator:
private int m1(int a)
private int m2(int a)
return a + a;
private void button3_Click(object sender, EventArgs e)
int j = 0;
for (int i = 0; i < 10; i++)
j = (i > 5) ? m1(i) : m2(i);
If you don't want to use a value returned by the operator - you just want to decide which method to execute, use if - else or switch - case expressions.