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
Is it good to use var in c#?
What is the difference between CreateObject() and GetObject()?
What is string in c# net?
How are methods overloaded?
What is the difference between array and list in c#?
What is icollection in c#?
What is different between Static Constructor and Private Constructor?
Explain the accessibility modifier protected internal?
What is an extension method in c#?
how to insert the data from the grid view to database table though button click.pls send the answer to mail id suri1319@gmail.com
Does main have to be static c#?
What is method in c#?
Can we overload the main method in c#?
What is value c#?
Explain the steps to create satellite assembly?