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
Why do we still see so much non-oo code written in c# today?
What are the steps to make an assembly to public?
What is firstordefault c#?
What is Co- and Contra-Variance in C#?
Can a constructor be private in c#?
What are circular references?
What is int parse in c#?
Can a class be protected in c#?
Can an interface extend a class c#?
Can int be null c#?
Can you inherit from a sealed class?
Is .net and c# the same?
How a two-dimensional array declared in C#?
What floating point types is supported in C#?
When a Static Constructor is called in a Class?