What will happen,when we compile below C# code?
private void sum(int a,int b)
return a + b;

 Posted by vishalneeraj-24503 on 10/8/2014 | Category: C# Interview questions | Views: 2453 | Points: 40

It will give below compile-time error as:-
Since '_Default.sum()' returns void, a return keyword must not be followed by an object expression.
Means if the return type is void,then we need not return any value from code as void returns Nothing.

Asked In: Many Interviews | Alert Moderator 

Comments or Responses

Login to post response