Click here to Skip to main content
15,896,207 members

Welcome to the Lounge

   

For discussing anything related to a software developer's life but is not for programming questions. Got a programming question?

The Lounge is rated Safe For Work. If you're about to post something inappropriate for a shared office environment, then don't post it. No ads, no abuse, and no programming questions. Trolling, (political, climate, religious or whatever) will result in your account being removed.

 
GeneralRe: Another C# syntax to wish for (or any C class language) Pin
jsc4227-Sep-16 3:23
professionaljsc4227-Sep-16 3:23 
GeneralRe: Another C# syntax to wish for (or any C class language) Pin
kalberts27-Sep-16 3:35
kalberts27-Sep-16 3:35 
GeneralRe: Another C# syntax to wish for (or any C class language) Pin
Marc Clifton27-Sep-16 4:20
mvaMarc Clifton27-Sep-16 4:20 
GeneralRe: Another C# syntax to wish for (or any C class language) Pin
kalberts27-Sep-16 4:31
kalberts27-Sep-16 4:31 
GeneralRe: Another C# syntax to wish for (or any C class language) Pin
Marc Clifton28-Sep-16 15:33
mvaMarc Clifton28-Sep-16 15:33 
GeneralRe: Another C# syntax to wish for (or any C class language) Pin
Ryan Peden27-Sep-16 5:25
professionalRyan Peden27-Sep-16 5:25 
GeneralRe: Another C# syntax to wish for (or any C class language) Pin
BillWoodruff27-Sep-16 17:05
professionalBillWoodruff27-Sep-16 17:05 
GeneralRe: Another C# syntax to wish for (or any C class language) Pin
PIEBALDconsult28-Sep-16 11:05
mvePIEBALDconsult28-Sep-16 11:05 
I disagree with "two alternate loop 'tails' ... another if the loop was left prematurely" -- that can be handled at the test site.


Almost like giving a while an else. Big Grin | :-D

Just for fun, I altered a simple while loop into the following attrocity:

C#
while ( true ) if ( ( ch = sr.Read() ) != -1 )
{
  System.Console.WriteLine ( "{0} {1} {2}" , i , ch , (char) ch ) ;

  if ( ch == 26 )
  {
    System.Console.WriteLine ( "Found a char 26 at offset {0}" , i ) ;

    break ;
  }

  i++ ;
}
else
{
  System.Console.WriteLine ( "Reached the EOF" ) ;

  break ;
}


Just be sure to break out of the else. WTF | :WTF:


Now to attempt:

# define whilst(x) while ( true ) if ( x )

Cool | :cool:



Edit:

C#
# define whilst(x,y) while ( x ) if ( y )

...

int ch ;
int i = 0 ;

whilst ( sr.BaseStream.CanRead , ( ch = sr.Read() ) != -1 )
{
  System.Console.WriteLine ( "{0} {1} {2}" , i , ch , (char) ch ) ;

  if ( ch == 26 )
  {
    System.Console.WriteLine ( "Found a char 26 at offset {0}" , i ) ;

    sr.BaseStream.Close() ;
  }

  i++ ;
}
else
{
  System.Console.WriteLine ( "Reached the EOF" ) ;

  sr.BaseStream.Close() ;
}


Badger | [badger,badger,badger,badger...]

modified 28-Sep-16 17:43pm.

GeneralRe: Another C# syntax to wish for (or any C class language) Pin
lopatir28-Sep-16 19:49
lopatir28-Sep-16 19:49 
GeneralRe: Another C# syntax to wish for (or any C class language) Pin
kalberts29-Sep-16 0:49
kalberts29-Sep-16 0:49 
GeneralHmm, I am starting to wonder about recruitment... Pin
glennPattonWork327-Sep-16 0:09
professionalglennPattonWork327-Sep-16 0:09 
PraiseRe: Hmm, I am starting to wonder about recruitment... Pin
Duncan Edwards Jones27-Sep-16 0:17
professionalDuncan Edwards Jones27-Sep-16 0:17 
GeneralRe: Hmm, I am starting to wonder about recruitment... Pin
glennPattonWork327-Sep-16 0:25
professionalglennPattonWork327-Sep-16 0:25 
GeneralRe: Hmm, I am starting to wonder about recruitment... Pin
dandy7227-Sep-16 7:38
dandy7227-Sep-16 7:38 
GeneralRe: Hmm, I am starting to wonder about recruitment... Pin
glennPattonWork327-Sep-16 7:54
professionalglennPattonWork327-Sep-16 7:54 
GeneralRe: Hmm, I am starting to wonder about recruitment... Pin
Daniel Pfeffer27-Sep-16 0:18
professionalDaniel Pfeffer27-Sep-16 0:18 
GeneralRe: Hmm, I am starting to wonder about recruitment... Pin
glennPattonWork327-Sep-16 0:23
professionalglennPattonWork327-Sep-16 0:23 
GeneralRe: Hmm, I am starting to wonder about recruitment... Pin
dan!sh 27-Sep-16 0:39
professional dan!sh 27-Sep-16 0:39 
GeneralRe: Hmm, I am starting to wonder about recruitment... Pin
glennPattonWork327-Sep-16 0:50
professionalglennPattonWork327-Sep-16 0:50 
GeneralRe: Hmm, I am starting to wonder about recruitment... Pin
dan!sh 27-Sep-16 0:52
professional dan!sh 27-Sep-16 0:52 
GeneralRe: Hmm, I am starting to wonder about recruitment... Pin
glennPattonWork327-Sep-16 0:58
professionalglennPattonWork327-Sep-16 0:58 
GeneralRe: Hmm, I am starting to wonder about recruitment... Pin
OriginalGriff27-Sep-16 1:14
mveOriginalGriff27-Sep-16 1:14 
GeneralRe: Hmm, I am starting to wonder about recruitment... Pin
Maximilien27-Sep-16 2:55
Maximilien27-Sep-16 2:55 
GeneralRe: Hmm, I am starting to wonder about recruitment... Pin
glennPattonWork327-Sep-16 3:05
professionalglennPattonWork327-Sep-16 3:05 
GeneralRe: Hmm, I am starting to wonder about recruitment... Pin
lopatir28-Sep-16 20:20
lopatir28-Sep-16 20:20 

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.