C# Function Overload
class test{
public void sum()
{
int a, b, c;
Console.Write("Enter first number>> ");
a = int.Parse(Console.ReadLine());
Console.Write("Enter second number>> ");
b = int.Parse(Console.ReadLine());
c=a+b;
Console.Write("\nA={0}\nB={1}\nSum={2}",a,b,c);
}
public int sum(int a, int b)
{
return a + b;
}
public int sum(int a)
{
return a + a;
}
}
class Program
{
static void Main(string[] args)
{
test ob = new test();
ob.sum();
Console.WriteLine("\nSum={0}", ob.sum(11, 55));
Console.WriteLine("\nSum={0}", ob.sum(9));
}
}
Next Topic
No comments:
Post a Comment