correcting in the code snippet

What is wrong with this section of code, is it something to do with the naming, datatypes, the structure of comments.

        someFunction(int[] a)                  
        {
            // print out entire array
for (int i = 0; i < a.Length - 1; i++)
label1.Text += a[i] + " "                  

            for (int i = 0; i < a.Length - 1; i++)
            {
                string ff;
                for (int j = 0 ; j < a.Length - 1, j++)
                {
                    if (a[j] > a[j+1])
                    {
                        bTemp = a[j];
                        a[j] = a[j+1];
                        a[j+1] = bTemp;
                    }
                }
            }

            /* print out entire array
            for (int i = 0; i < a.Length; i++)
                label2.Text += a[i].ToString() + " ";
        }

any help would be appreciated

Thanks,
Anagm
anagmAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

sk1nn4Commented:
There are numerous things wrong
1.  for (int j = 0 ; j < a.Length - 1, j++) needs a ; not a , so it should be  for (int j = 0 ; j < a.Length - 1; j++)
2. bTemp needs to be declared as int bTemp (and its a integer not a boolean like the b implies)
3.    The comment /* print out entire array
            for (int i = 0; i < a.Length; i++)
                label2.Text += a[i].ToString() + " ";
   needs to be closed with a */
4. The line label1.Text += a[i] + " " needs a ; at the end
:)
Fernando SotoRetiredCommented:

// You need to give it a return type, void if non
void someFunction(int[] a)              
{
        // If bTemp was not decleared in globel need to decleare it here
      int bTemp = 0;
                  
      // print out entire array
        // i < a.Length and not i < a.Length -1 otherwise you will be one short
      for (int i = 0; i < a.Length; i++)
            label1.Text += a[i] + " ";

      for (int i = 0; i < a.Length - 1; i++)
      {
            // string ff;  This is not being used can be removed
            for (int j = 0 ; j < a.Length - 1; j++)
            {
                  if (a[j] > a[j+1])
                  {
                        bTemp = a[j];
                        a[j] = a[j+1];
                        a[j+1] = bTemp;
                  }
            }
      }

      // print out entire array <- this is OK
        /* print out entire array <- this is OK  */
        /* print out entire array <- this is not OK
      for (int i = 0; i < a.Length; i++)
            label2.Text += a[i].ToString() + " ";
}

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Bob LearnedCommented:
I could swear that this looks like a homework assignment.

Bob
Fernando SotoRetiredCommented:
Yes, but he did write his own code which just needed a little help with and the logic was correct.
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
C#

From novice to tech pro — start learning today.