TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
Aman Jen
NA
141
40.6k
not all code paths return value in C# code
Sep 20 2013 10:33 AM
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();
}
}
}
Reply
Answers (
1
)
DATAGRIDVIEW IN WINDOW C#
Exception handleing