public static boolean moreThanOnce(ArrayList<Integer> list , int number) {
int count = 0;
for (int i = 1; i < list.size(); i ++ ) {
if (list.get(i) == number) {
count ++;
if (count > 1) {
return true;
}
else //delete this line
return false; // delete this line
}
}
return false;//add return here
}
Для устранения ошибки требуется только возврат за пределы цикла for. И я думаю, вы должны удалить еще логику, которая делает метод не может найти число, которое появляется более одного раза правильно.
Это легко выполнимо, если вы добавите запрограммированные маршруты выше общих:
// AboutController.Index()
routes.MapRoute(
"About",
"about",
new { controller = "About", action = "Index" });
// HomeController.Index()
routes.MapRoute(
"Home",
"home",
new { controller = "Home", action = "Index" });
// ArticleController.Index(string category, string pagename)
routes.MapRoute(
"Article",
"{category}/{pagename}",
new { controller = "Article", action = "Index" });
Все они могут использовать один и тот же контроллер. если бы вы хотели, но было бы немного легче, если бы они использовали отдельные.
Единственная проблема, с которой вы столкнулись бы с этим, - это если бы у вас была категория под названием «около» или «дом», но я вряд ли это представлю.
Следует также отметить, что вам не нужно использовать ASP.NET MVC, чтобы использовать возможность маршрутизации .
To avoid the problems you mention with the static pages (about, home, etc.) you could take a few different aproaches:
Other caveats/gotchas:
You'll also need to ensure that your category names and page names are unique. On a large site this is not always trivial (or even practical) which is probably why you see URLs like the ones here on Stack Overflow where the question id is actually in the URL, and the "page name" part is just SEO sugar.
You'll need to have a strategy for handling name changes. If a category name or page name is changed, you'll need to have something in place to redirect links to the old names to the new ones for maximum SEO goodness. You'll also want to make sure that the new name of a category/page isn't the same as the old name of another category/page, which adds a bit more complexity to the picture.
All that said, it is feasible, and it it certainly worthwhile in my opinion. Especially if you expect most of your traffic to come from search engines.