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 the difference between method parameters and method arguments. Give an example?
What is the implicit name of the parameter that gets passed into the class set method?
What is instantiating a class?
what is c# command?
Explain the difference between “system.array.clone()” and “system.array.copyto()” in c#?
Is collection a data structure?
I was trying to use an out int parameter in one of my functions. How should I declare the variable that I am passing to it?
Can a private virtual method can be overridden?
Are multiple data types stored in System.Array?
Can abstract class be instantiated c#?
What happens during the process of boxing?
How long does it take to learn c# programming?
Explain the concepts of cts and cls(common language specification).
How do I register my code for use by classic com clients?
What is sealed class in c#?