[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

a c# loop

Posted on 2011-05-02
3
Medium Priority
?
309 Views
Last Modified: 2012-05-11
What is wrong?
for (int i = 0; i < list.Count; i++)
       {
             for(int j=0 && j!=i;j<list.Count;j++)
             {
                   \\ do something
             }
}

Open in new window

0
Comment
Question by:zhshqzyc
3 Comments
 
LVL 45

Accepted Solution

by:
AndyAinscow earned 400 total points
ID: 35505492
This:  int j=0 && j!=i;j<list.Count;j++

You might have wanted: int j=0; j!=i && j<list.Count;j++
0
 
LVL 23

Assisted Solution

by:wdosanjos
wdosanjos earned 100 total points
ID: 35505495
I'm not sure what you want to do with "int j=0 && j!=i" (that's not a valid construct on the for initializer.  Here is a possibility:

for (int i = 0; i < list.Count; i++)
{
    for(int j=0;j<list.Count;j++)
    {
          if (j!=i)
          {
                   \\ do something
          }
    }
}

Open in new window

0
 

Author Closing Comment

by:zhshqzyc
ID: 35505539
Thanks
0

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Entity Framework is a powerful tool to help you interact with the DataBase but still doesn't help much when we have a Stored Procedure that returns more than one resultset. The solution takes some of out-of-the-box thinking; read on!
High user turnover can cause old/redundant user data to consume valuable space. UserResourceCleanup was developed to address this by automatically deleting user folders when the user account is deleted.
this video summaries big data hadoop online training demo (http://onlineitguru.com/big-data-hadoop-online-training-placement.html) , and covers basics in big data hadoop .
Integration Management Part 2
Suggested Courses

834 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question