Hi, In below code , I have public add function, wherein if I write it as :
public int add()
it shows error:not all code paths return a value.
As is this function is goin to return a value how com this error.
Plz help..!!!!!!
using System;
namespace Property_Get_Set_2
{
class input
{
private int num1, num2, result;
public void add()
{
result = num1 + num2;
Console.WriteLine("Sum of Number is : \t" + result);
Console.ReadLine();
}
public int Number1
{
get
{
return num1;
}
set
{
num1 = value;
}
}
public int Number2
{
get
{
return num2;
}
set
{
num2 = value;
}
}
}
class Program
{
static void Main(string[] args)
{
input Inpt = new input();
Console.Write("Enter First Number : ");
Inpt.Number1 = Convert.ToInt32(Console.ReadLine());
Console.Write("Enter Second Number : ");
Inpt.Number2 = Convert.ToInt32(Console.ReadLine());
Inpt.add();
Console.ReadLine();
}
}
}