Click here to Skip to main content
15,891,375 members
Home / Discussions / C#
   

C#

 
AnswerRe: how to get out from the outer for Pin
Eddy Vluggen17-Mar-09 0:27
professionalEddy Vluggen17-Mar-09 0:27 
AnswerRe: how to get out from the outer for Pin
Simon P Stevens17-Mar-09 0:29
Simon P Stevens17-Mar-09 0:29 
AnswerRe: how to get out from the outer for Pin
Eslam Afifi17-Mar-09 0:40
Eslam Afifi17-Mar-09 0:40 
AnswerRe: how to get out from the outer for PinPopular
Pete O'Hanlon17-Mar-09 0:53
mvePete O'Hanlon17-Mar-09 0:53 
GeneralRe: how to get out from the outer for Pin
Colin Angus Mackay17-Mar-09 0:58
Colin Angus Mackay17-Mar-09 0:58 
GeneralRe: how to get out from the outer for Pin
Simon P Stevens17-Mar-09 1:30
Simon P Stevens17-Mar-09 1:30 
GeneralRe: how to get out from the outer for Pin
Xmen Real 17-Mar-09 2:46
professional Xmen Real 17-Mar-09 2:46 
GeneralRe: how to get out from the outer for Pin
Pete O'Hanlon17-Mar-09 2:57
mvePete O'Hanlon17-Mar-09 2:57 
Xmen wrote:
Well well well, first of I'm not lazy


Perhaps not, but you aren't thinking about proper use of language constructs - hence my original comment.
int index = 0;
while (arrayx[index++] != 9)
{
}
That's how you'd do your example - now, you can justify yourself as long as you like but you are promoting a bad practice. Now, let's extend your sample to see why it's bad practice.
bool foundNine = false;
for (int i = 0; i < array.length; i++)
{
  if (array[i] == 9)
  {
    foundNine = true;
    break;
  }
}

if (foundNine && SomeOtherCondition())
{
  DoSomething(array[i]); // Oh, wait a second you can't do this here because you don't know what i is
}
Contrast this with:
int index = 0;
bool foundNine = false;
do
{
  if (array[index] == 9)
  {
    foundNine = true;
  }
  else
  {
    index++;
  }
} while (!foundNine);
if (foundNine && SomeOtherCondition())
{
  DoSomething(array[index]);
}
I don't know about you, but this doesn't feel like such a horrible hack.

"WPF has many lovers. It's a veritable porn star!" - Josh Smith

As Braveheart once said, "You can take our freedom but you'll never take our Hobnobs!" - Martin Hughes.


My blog | My articles | MoXAML PowerToys



GeneralRe: how to get out from the outer for Pin
Xmen Real 17-Mar-09 3:00
professional Xmen Real 17-Mar-09 3:00 
GeneralRe: how to get out from the outer for Pin
Pete O'Hanlon17-Mar-09 3:29
mvePete O'Hanlon17-Mar-09 3:29 
GeneralRe: how to get out from the outer for Pin
Xmen Real 17-Mar-09 3:35
professional Xmen Real 17-Mar-09 3:35 
GeneralRe: how to get out from the outer for Pin
Pete O'Hanlon17-Mar-09 3:42
mvePete O'Hanlon17-Mar-09 3:42 
GeneralRe: how to get out from the outer for Pin
Eddy Vluggen17-Mar-09 6:04
professionalEddy Vluggen17-Mar-09 6:04 
Questionhow can i change the sample rate and sample size of wave files Pin
ahmedhassan9617-Mar-09 0:12
ahmedhassan9617-Mar-09 0:12 
QuestionVS 2008 - Setup project: Change Link Icon in Program Menu Pin
dj_jeff17-Mar-09 0:10
dj_jeff17-Mar-09 0:10 
Questionhow to catch these events? Pin
abhiram_nayan17-Mar-09 0:01
abhiram_nayan17-Mar-09 0:01 
AnswerRe: how to catch these events? Pin
Eddy Vluggen17-Mar-09 0:50
professionalEddy Vluggen17-Mar-09 0:50 
GeneralRe: how to catch these events? Pin
abhiram_nayan17-Mar-09 1:02
abhiram_nayan17-Mar-09 1:02 
GeneralRe: how to catch these events? Pin
Eddy Vluggen17-Mar-09 1:41
professionalEddy Vluggen17-Mar-09 1:41 
QuestionWhat's name of this code ? Pin
Mohammad Dayyan16-Mar-09 23:28
Mohammad Dayyan16-Mar-09 23:28 
AnswerRe: What's name of this code ? Pin
DaveyM6916-Mar-09 23:30
professionalDaveyM6916-Mar-09 23:30 
Questionopenfiledialog Pin
abu anas alazuneh16-Mar-09 23:06
abu anas alazuneh16-Mar-09 23:06 
AnswerRe: openfiledialog Pin
SeMartens16-Mar-09 23:07
SeMartens16-Mar-09 23:07 
AnswerRe: openfiledialog Pin
Christian Graus16-Mar-09 23:08
protectorChristian Graus16-Mar-09 23:08 
AnswerRe: openfiledialog Pin
iamalik16-Mar-09 23:31
professionaliamalik16-Mar-09 23:31 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.