Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8125609
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T06:52:27+00:00 2026-06-06T06:52:27+00:00

Id need i in the Iteration method to be the return value for Iteration()….at

  • 0

Id need i in the Iteration method to be the return value for Iteration()….at the moment it is in error saying it has no return value. I assume since its in the for statement.

using System;

class Program
{
int i = 1;

static string globalValue = "I was declared outside any method";

static void Main()
{
    for (int b = 0; b < 101; b++)
    {
        Console.Write(Iteration());
    }
}
static string FizzBuzz()
{
    string f = "word1";

    return f;
}
static string Buzz()
{
    string b = "word2";

    return b;
}
static int Iteration()
{
    for (int i = 0; i < 101; i++)
    {
        return i;
    }



}

}

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-06T06:52:28+00:00Added an answer on June 6, 2026 at 6:52 am

    The C# compiler only has a limited capability of navigating your code in order to determine if your function will always return a value. While the code that you’ve written will always return, the compiler isn’t “smart enough” to figure that out.

    Just put a return -1; at the end of the function after the loop to satisfy the compiler.

    Though, of course, the code you have now doesn’t make much sense, as Iteration() will always return 0. It’s not going to go through the entire loop, since a function can only return one value. (Iterator blocks being a syntactic exception, but not an actual exception).

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I need to have my PHP extension return an array of objects, but I
I need to model a node in a tree. Node has children, of course,
I have a WCF service that has methods to return IEnumerable<T> collections of objects,
In my application,I need to do some iteration with the array-like object. So I
I need to sort a java collection of objects by an Integer value level.
i have a problem with my script i have a method that return a
I know find method finds the supplied key in std::map and return an iterator
I have a list of specific objects(meetings) which I need to group using a
I have a method that I call to make web service requests using GET.
I have to return array of objects from a method. The objects are initially

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.