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
harish reddy
NA
162
33.6k
Methods C Sharp
Feb 9 2018 8:30 PM
I am getting error " Not all code paths return a value" with this code? pls help.
static void Main(string[] args)
{
Console.WriteLine("Enter the lenth of Array");
int length = int.Parse(Console.ReadLine());
int[] array = new int[length];
for (int i = 0; i <= array.Length - 1; i++)
{
Console.WriteLine("Enter {0} element" ,i);
array[i] = int.Parse(Console.ReadLine());
}
Console.WriteLine("Enter the element");
int element = int.Parse(Console.ReadLine());
Positionoffirst(element, array);
Console.WriteLine(Positionoffirst(element,array));
}
static int Positionoffirst(int element, int[] array)
{
for (int i = 0; i <= array.Length-1; i++)
{
if (array[i]==element)
{
if (array[i]>array[i-1] && array[i]>array[i+1])
{
return 1;
}
}
else
{
return -1;
}
}
Reply
Answers (
1
)
OCR not reading images created from MemoryStream or Bitmap
general question