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 are the fundamental differences between value types and reference types?
Can you explicitly call a destructor?
What are All kind of access specifiers for a class and for methods
Can you inherit multiple abstract classes in c#?
What is static variable in c#?
Please write a program to display “welcome to bestinterviewquestion.com” in c#?
What is c sharp used for?
Explain streamreader/streamwriter class?
How big is int16?
What is a console?
Is c# the same as d flat?
Is it true that all c# types derive from a common base class?
What is a dictionary in c#?
Can I use ReaderWriterLock instead of Monitor.Enter/Exit for Threading?
What is ilist c#?