Skip to main content
added syntax-highlighting
Source Link
Deduplicator
  • 9.1k
  • 5
  • 33
  • 52

This metaphor almost certainly refers to the practice of establishing the first conditional check in a while loop. If you don't do this, the loop won't work. It is a well-established pattern, and it hasn't changed since the while loop was invented. The requirement for setting the initial condition in a while loop is not a defect.

int i = 0; // prime the pump
while (i < 10)
{
    Console.Write("While statement ");
    Console.WriteLine(i);
    i++; // set condition again
}
int i = 0; // prime the pump
while (i < 10)
{
    Console.Write("While statement ");
    Console.WriteLine(i);
    i++; // set condition again
}

The primer can be a read statement, or whatever properly sets the initial condition. Setting the initial condition using a read statement is called a "Priming Read."

string line;

using (StreamReader file = new StreamReader("c:\\test.txt"))
{
    line = file.ReadLine(); // Priming read.
    while(line != null)
    {
        Console.WriteLine (line);
        line = file.ReadLine(); // Subsequent reads.   
    }
}
string line;

using (StreamReader file = new StreamReader("c:\\test.txt"))
{
    line = file.ReadLine(); // Priming read.
    while(line != null)
    {
        Console.WriteLine (line);
        line = file.ReadLine(); // Subsequent reads.   
    }
}

In C#, the two Readline() calls can be combined into a single statement within the conditional:

while ((line = r.ReadLine()) != null)
{
    Console.WriteLine (line);
}
while ((line = r.ReadLine()) != null)
{
    Console.WriteLine (line);
}

This metaphor almost certainly refers to the practice of establishing the first conditional check in a while loop. If you don't do this, the loop won't work. It is a well-established pattern, and it hasn't changed since the while loop was invented. The requirement for setting the initial condition in a while loop is not a defect.

int i = 0; // prime the pump
while (i < 10)
{
    Console.Write("While statement ");
    Console.WriteLine(i);
    i++; // set condition again
}

The primer can be a read statement, or whatever properly sets the initial condition. Setting the initial condition using a read statement is called a "Priming Read."

string line;

using (StreamReader file = new StreamReader("c:\\test.txt"))
{
    line = file.ReadLine(); // Priming read.
    while(line != null)
    {
        Console.WriteLine (line);
        line = file.ReadLine(); // Subsequent reads.   
    }
}

In C#, the two Readline() calls can be combined into a single statement within the conditional:

while ((line = r.ReadLine()) != null)
{
    Console.WriteLine (line);
}

This metaphor almost certainly refers to the practice of establishing the first conditional check in a while loop. If you don't do this, the loop won't work. It is a well-established pattern, and it hasn't changed since the while loop was invented. The requirement for setting the initial condition in a while loop is not a defect.

int i = 0; // prime the pump
while (i < 10)
{
    Console.Write("While statement ");
    Console.WriteLine(i);
    i++; // set condition again
}

The primer can be a read statement, or whatever properly sets the initial condition. Setting the initial condition using a read statement is called a "Priming Read."

string line;

using (StreamReader file = new StreamReader("c:\\test.txt"))
{
    line = file.ReadLine(); // Priming read.
    while(line != null)
    {
        Console.WriteLine (line);
        line = file.ReadLine(); // Subsequent reads.   
    }
}

In C#, the two Readline() calls can be combined into a single statement within the conditional:

while ((line = r.ReadLine()) != null)
{
    Console.WriteLine (line);
}
Bounty Ended with 50 reputation awarded by candied_orange
added 22 characters in body
Source Link
Robert Harvey
  • 200.1k
  • 55
  • 468
  • 679

This metaphor almost certainly refers to the practice of establishing the first conditional check in a while loop. If you don't do this, the loop won't work. It is a well-established pattern, and it hasn't changed since the while loop was invented. The requirement for setting the initial condition in a while loop is not a defect.

int i = 0; // prime the pump
while (i < 10)
{
    Console.Write("While statement ");
    Console.WriteLine(i);
    i++; // set condition again
}

The primer can be a read statement, or whatever properly sets the initial condition. Setting the initial condition using a read statement is called a "Priming Read."

string line;

using (StreamReader file = new StreamReader("c:\\test.txt"))
{
    line = file.ReadLine(); // Priming read.
    while(line != null)
    {
        Console.WriteLine (line);
        line = file.ReadLine(); // Subsequent reads.   
    }
}

In C#, the two Readline() calls can be combined into a single statement within the conditional:

while ((line = r.ReadLine()) != null)
{
    Console.WriteLine (line);
}

This metaphor almost certainly refers to the practice of establishing the first conditional check in a while loop. If you don't do this, the loop won't work. It is a well-established pattern, and it hasn't changed since the while loop was invented. The requirement for setting the initial condition in a while loop is not a defect.

int i = 0; // prime the pump
while (i < 10)
{
    Console.Write("While statement ");
    Console.WriteLine(i);
    i++; 
}

The primer can be a read statement, or whatever properly sets the initial condition. Setting the initial condition using a read statement is called a "Priming Read."

string line;

using (StreamReader file = new StreamReader("c:\\test.txt"))
{
    line = file.ReadLine(); // Priming read.
    while(line != null)
    {
        Console.WriteLine (line);
        line = file.ReadLine(); // Subsequent reads.   
    }
}

In C#, the two Readline() calls can be combined into a single statement within the conditional:

while ((line = r.ReadLine()) != null)
{
    Console.WriteLine (line);
}

This metaphor almost certainly refers to the practice of establishing the first conditional check in a while loop. If you don't do this, the loop won't work. It is a well-established pattern, and it hasn't changed since the while loop was invented. The requirement for setting the initial condition in a while loop is not a defect.

int i = 0; // prime the pump
while (i < 10)
{
    Console.Write("While statement ");
    Console.WriteLine(i);
    i++; // set condition again
}

The primer can be a read statement, or whatever properly sets the initial condition. Setting the initial condition using a read statement is called a "Priming Read."

string line;

using (StreamReader file = new StreamReader("c:\\test.txt"))
{
    line = file.ReadLine(); // Priming read.
    while(line != null)
    {
        Console.WriteLine (line);
        line = file.ReadLine(); // Subsequent reads.   
    }
}

In C#, the two Readline() calls can be combined into a single statement within the conditional:

while ((line = r.ReadLine()) != null)
{
    Console.WriteLine (line);
}
deleted 72 characters in body
Source Link
Robert Harvey
  • 200.1k
  • 55
  • 468
  • 679

This metaphor almost certainly refers to the practice of establishing the first conditional check in a while loop. If you don't do this, the loop won't work. It is a well-established pattern, and it hasn't changed since the while loop was invented. The requirement for setting the initial condition in a while loop is not a defect.

int i = 0; // prime the pump
while (i < 10)
{
    Console.Write("While statement ");
    // Write the index to the screen.
    Console.WriteLine(i);
    // Increment the variable.
    i++; 
}

The primer can be a read statement, or whatever properly sets the initial condition. Setting the initial condition using a read statement is called a "Priming Read."

string line;

using (StreamReader file = new StreamReader("c:\\test.txt"))
{
    line = file.ReadLine(); // Priming read.
    while(line != null)
    {
        Console.WriteLine (line);
        line = file.ReadLine(); // Subsequent reads.   
    }
}

In C#, the two Readline() calls can be combined into a single statement within the conditional:

while ((line = r.ReadLine()) != null)
{
    Console.WriteLine (line);
}

This metaphor almost certainly refers to the practice of establishing the first conditional check in a while loop. If you don't do this, the loop won't work. It is a well-established pattern, and it hasn't changed since the while loop was invented. The requirement for setting the initial condition in a while loop is not a defect.

int i = 0; // prime the pump
while (i < 10)
{
    Console.Write("While statement ");
    // Write the index to the screen.
    Console.WriteLine(i);
    // Increment the variable.
    i++;
}

The primer can be a read statement, or whatever properly sets the initial condition. Setting the initial condition using a read statement is called a "Priming Read."

string line;

using (StreamReader file = new StreamReader("c:\\test.txt"))
{
    line = file.ReadLine(); // Priming read.
    while(line != null)
    {
        Console.WriteLine (line);
        line = file.ReadLine(); // Subsequent reads.   
    }
}

In C#, the two Readline() calls can be combined into a single statement within the conditional:

while ((line = r.ReadLine()) != null)
{
    Console.WriteLine (line);
}

This metaphor almost certainly refers to the practice of establishing the first conditional check in a while loop. If you don't do this, the loop won't work. It is a well-established pattern, and it hasn't changed since the while loop was invented. The requirement for setting the initial condition in a while loop is not a defect.

int i = 0; // prime the pump
while (i < 10)
{
    Console.Write("While statement ");
    Console.WriteLine(i);
    i++; 
}

The primer can be a read statement, or whatever properly sets the initial condition. Setting the initial condition using a read statement is called a "Priming Read."

string line;

using (StreamReader file = new StreamReader("c:\\test.txt"))
{
    line = file.ReadLine(); // Priming read.
    while(line != null)
    {
        Console.WriteLine (line);
        line = file.ReadLine(); // Subsequent reads.   
    }
}

In C#, the two Readline() calls can be combined into a single statement within the conditional:

while ((line = r.ReadLine()) != null)
{
    Console.WriteLine (line);
}
added 115 characters in body
Source Link
Robert Harvey
  • 200.1k
  • 55
  • 468
  • 679
Loading
Source Link
Robert Harvey
  • 200.1k
  • 55
  • 468
  • 679
Loading