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


Please Help Members By Posting Answers For Below Questions

Why do we still see so much non-oo code written in c# today?

587


What are the steps to make an assembly to public?

595


What is firstordefault c#?

628


What is Co- and Contra-Variance in C#?

620


Can a constructor be private in c#?

565






What are circular references?

600


What is int parse in c#?

575


Can a class be protected in c#?

564


Can an interface extend a class c#?

605


Can int be null c#?

607


Can you inherit from a sealed class?

573


Is .net and c# the same?

639


How a two-dimensional array declared in C#?

645


What floating point types is supported in C#?

679


When a Static Constructor is called in a Class?

655