Copying and Pasting cs Code

In cs, like in almost any computer programming language, reading data from a file can be tricky. You add extra lines of code to tell the computer what to do. Sometimes you can copy and paste these lines from other peoples’ code.

For example, you can follow the pattern in this listing:

  private bool show(){

   //if this block is one that should not be shown
   if (this.GetBlockNumber(this.x, this.y, this.z) == -2) return false;

   if (this.axis == "x") {
    //if this is on the edge then don't display
    if(this.x == 2) return false;
    //check if the neighboring block should not be shown
    if(this.GetBlockNumber (this.x + 1, this.y, this.z) == -2) return false;
   }
   if (this.axis == "y") {
    //if this is on the edge then don't display
    if(this.y == 2) return false;
    //check if the neighboring block should not be shown
    if(this.GetBlockNumber (this.x, this.y+1, this.z) == -2) return false;
   }
   if (this.axis == "z") {
    //if this is on the edge then don't display
    if(this.z == 2) return false;
    //check if the neighboring block should not be shown
    if(this.GetBlockNumber (this.x, this.y, this.z+1) == -2) return false;
   }

   return true;
  }