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:

       public EigenObjectRecognizer(Image[] images, String[] labels, double eigenDistanceThreshold, ref MCvTermCriteria termCrit)
       {
          Debug.Assert(images.Length == labels.Length, "The number of images should equals the number of labels");
          Debug.Assert(eigenDistanceThreshold >= 0.0, "Eigen-distance threshold should always >= 0.0");

          CalcEigenObjects(images, ref termCrit, out _eigenImages, out _avgImage);

          /*
          _avgImage.SerializationCompressionRatio = 9;

          foreach (Image img in _eigenImages)
              //Set the compression ration to best compression. The serialized object can therefore save spaces
              img.SerializationCompressionRatio = 9;
          */

          _eigenValues = Array.ConvertAll, Matrix>(images,
              delegate(Image img)
              {
                 return new Matrix(EigenDecomposite(img, _eigenImages, _avgImage));
              });

          _labels = labels;

          _eigenDistanceThreshold = eigenDistanceThreshold;
       }