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 / anandraj
class Program
{
void add()
{
int x = 10, y = 20,sum;
fun(x,y,out sum);//changing the parameters
Console.WriteLine("{0}", sum);
}
void fun(int x,int y,out int sum)//changing the
parameter and using out keyword
{
sum = x + y;
}
static void Main(string[] args)
{
Program f = new Program();
f.add();
}
| Is This Answer Correct ? | 6 Yes | 0 No |
Post New Answer View All Answers
What is difference between a constant and read-only in C#?
Can we override static class in c#?
Explain the difference between pass by value and pass by reference.
What is difference between assembly and namespace?
What is a console in c#?
What is Inheritance in C#?
What is the data encapsulation?
What do u mean by delegation of authority?
Difference between StackPanel and RelativePanel ?
What is ispostback c#?
What does private void mean in c#?
Can partial class be inherited?
Explain “static” keyword in c#?
Why do we use delegates?
Can we write class inside a class in c#?