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
What is thread life cycle in c#?
Explain the feature of c# language?
Is c# or c++ better for games?
What is different between Boxing and Unboxing?
What is expression c#?
Is it good to use var in c#?
What is difference between arraylist and list in c#?
What do you use c# for?
How can you sort strings in array that are passed to method as arguments?
What is array c#?
What is null character in string?
Explain constructor in c#?
How do I join one form to another in c#?
What is the difference between a private assembly and a shared assembly?
What are the benefits of using windows services: