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.....

Answers were Sorted based on User's Feedback



class Program { void add() { int x=10, y=20; ..

Answer / 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

class Program { void add() { int x=10, y=20; ..

Answer / 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

class Program { void add() { int x=10, y=20; ..

Answer / nvk

The Variable Sum Is Not defined

Is This Answer Correct ?    1 Yes 4 No

Post New Answer

More C Sharp Interview Questions

Describe an abstract class?

0 Answers   Siebel,


What do you mean by the delegate in c#?

0 Answers  


Define c# delegate?

0 Answers  


Which debugging tools you can use in the .NET ssSDK?

0 Answers   Siebel,


Can var be null c#?

0 Answers  






2. What happened when BO object has been called?

0 Answers   Mphasis,


What are the extension methods in c#?

0 Answers  


What is meaning of type safety in c#?

0 Answers  


What are the Types of optimization and name a few and how do u do?

0 Answers   BirlaSoft,


Hello Friends..am Mohammed riyash..final year BCA in Jamal Mohamed College 2009. Trichy. My doubt is while connecting SQL2005 Built in Database withing the Visual Studio 2005 Framework.. I am getting the error.. That " An Error occurred and it may be due to , under the default settings of the Server, the connection cannot be established.." But the code works in MS Access for me.. Both in VB.Net and C#.Net am getting the same error.. Any genius please Message me to 9994558822 or mail me.. riyash.ips@gmail.com

3 Answers  


What is serialization of data?

0 Answers  


What is escape sequence in c#?

0 Answers  


Categories