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 3681256
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 19, 20262026-05-19T03:40:12+00:00 2026-05-19T03:40:12+00:00

Sorry, hope no one marks me down for a noob question, I don’t have

  • 0

Sorry, hope no one marks me down for a noob question, I don’t have a C# ref book yet><

Is there a way to put an extra conditional statement inside the foreach loop, for example:

string[] giggles = new string[6] { "one", "two", "three", "four", "five", "Six" };
    int i = 0;

    foreach (string gig in giggles && i < 4)
    {
        lblDo.Text = gig;
        i++;
    }

This obviously doesn’t work, but is there something similar I can use or am I stuck with using an if/break statement in the loop? Thanks!

  • 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-05-19T03:40:12+00:00Added an answer on May 19, 2026 at 3:40 am

    You will have to use if/break, or a for loop. The foreach loop is almost intentionally limited because the point is simply to iterate over an enumerable collection*. If you want more concise loop control, you are to use for loops, while loops or do-while loops.

    *actually, anything that has a GetEnumerator() method.

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

Sidebar

Related Questions

Sorry for the basic question - I'm a .NET developer and don't have much
(Sorry in advance if the question is stupid or obvious -- I don't have
Sorry for the vague question, but I hope for an experienced Haskeller this is
This question is related to my other one and I hope to get some
OK, I hope I explain this one correctly. I have a struct: typedef struct
I hope I can explain the question well enough. I have a table with
Question: I've profiled my Python program to death, and there is one function that
Is there a method to have two configurations that automatically use one when online
Sorry for this not being a real question, but Sometime back i remember seeing
Sorry the title isn't more help. I have a database of media-file URLs that

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.