adspace


class Program
{




void add()
{
int x=10, y=20;
fun();
Console.WriteLine("{0}", sum);

}

void fun()
{
int sum;
sum = x + y;

}
static void Main(string[] args)
{
Program f =new Program();
f.add();

}
}

Debug above program.....

Answer Posted / simhachalam

Actually you defined x,y variable in add() function so that
variables you can't access outside of method .finally u got
error is undefined variables x,y.

Is This Answer Correct ?    2 Yes 1 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What is expression tree in c#?

998


How to assign Null value to Var?

1064


Which namespaces are necessary to create a localized application?

1142


How do you inherit a class into other class in c#?

995


What is an abstract class c#?

969


Why can't we use a static class instead of singleton?

954