Answer: '_Default.Calculate(int,int)': not all code paths return a value
Above error means if we have defined any method with return type then we have to explicitly return that type otherwise it will not compile and will throw above error.So we have to re-write below code as:-
private int Calculate(int a, int b)
{
int i = a;
int j = b;
int k = i + j;
return k;
}
Asked In: Many Interviews |
Alert Moderator