473,320 Members | 1,916 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

c# i'm having this error please help me!

Expand|Select|Wrap|Line Numbers
  1. public bool searchGame(string gameName)
  2.     {
  3.         string[] searchGame = new string[] { "Tibia", "Combat Arms", "Need for Speed", "Moto GP", "Risk", "Red Alert", "Monopoly", "Scrabble" };
  4.  
  5.         if (gameName.Length > 0)
  6.         {
  7.             for (int i = 0; i <= 7; i++)
  8.  
  9.                 if (searchGame[i] == gameName)
  10.                 {
  11.                     return true;
  12.                 }
  13.         }
  14.         else
  15.         {
  16.             return false;
  17.         }
  18.     }
  19.  
// the error stated "Service.searchGame(string): not all code paths return a value"

anyone knows how to solve this?
Dec 7 '08 #1
2 1218
JosAH
11,448 Expert 8TB
Suppose gameName is not an empty string but it is not a valid game name; what does your method return? That's what the compiler is complaining about.

btw, this is the C and C++ forum. C# is an entirely different language. Questions on C# should be posted in the .NET forum. Oh, and don't double post.

kind regards,

Jos (moderator)
Dec 7 '08 #2
Markus
6,050 Expert 4TB
I think your second 'if' statement needs an 'else' counterpart that returns false. The error says it all: not every possible path returns a value.
Dec 7 '08 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

1
by: Anand | last post by:
Hi i am having trouble adding a recordset into the access database, the code seems to be working fine it passs and parses through all variables just fine without showing any errors and also when i...
4
by: MLH | last post by:
I am having failures processing the following command and I wonder if you can tell me what I must do in order to have success. When I try to run source mysql_dump.sql.txt ==> it is a problem...
5
by: Codeman II | last post by:
Hi there, I am building a form where the user must upload a picture and fill in his details. Now I have a problem as all of this is on the same form. How will I be able to have the Browse...
9
by: TD | last post by:
I am trying to add transactions to my code. The original code worked fine until I followed an example to setup transactions, now the code does strange things, but no error messages. Could...
4
by: wASP | last post by:
Hi, I'm a newbie starting up with ASP.NET, and I'm getting off to a wonderful start - and when I tell you "wonderful" I'm being sarcastic. My OS is Win 2000 SP4. I've gotten IIS installed,...
7
by: Adrian Parker | last post by:
Having a problem with validators. Because we want to only test whether the current field in a changed event is valid before we process the change code, I have tried to turn off all validators for...
3
by: Michael | last post by:
Hi all, I'm having trouble PInvoking a TCHAR within a struct. I'll paste the specific struct's API definition below. I've tried so many numerous variations. The main Win32 error I get is...
9
by: Mike | last post by:
Hi, Just a simple question: why the compiler doesn't report error when accessing a private member function inside a function having template type ? For example: #include<iostream> using...
2
by: SajidKamal | last post by:
Dear Friends While Hosting My Application On Hosting Server, i am geting error bellow. please help me ought. Server Error in '/' Application....
2
by: rustyc | last post by:
Well, here's my first post in this forum (other than saying 'HI' over in the hi forum ;-) As I said over there: ... for a little side project at home, I'm writing a ham radio web site in...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.