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:

     bool ObjectIsSameWithInprecision(object one, object two)
     {
         if (one == null || two == null)
         {
             return one == null && two == null;
         }

         if (!one.Equals(two))
         {
             // if A is not B, lets check if A is almost B
             if (one is Vector3)
             {
                 Vector3 a = (Vector3)one;
                 Vector3 b = (Vector3)two;
                 if (a.AlmostEquals(b, PhotonNetwork.precisionForVectorSynchronization))
                 {
                     return true;
                 }
             }
             else if (one is Vector2)
             {
                 Vector2 a = (Vector2)one;
                 Vector2 b = (Vector2)two;
                 if (a.AlmostEquals(b, PhotonNetwork.precisionForVectorSynchronization))
                 {
                     return true;
                 }
             }
             else if (one is Quaternion)
             {
                 Quaternion a = (Quaternion)one;
                 Quaternion b = (Quaternion)two;
                 if (a.AlmostEquals(b, PhotonNetwork.precisionForQuaternionSynchronization))
                 {
                     return true;
                 }
             }
             else if (one is float)
             {
                 float a = (float)one;
                 float b = (float)two;
                 if (a.AlmostEquals(b, PhotonNetwork.precisionForFloatSynchronization))
                 {
                     return true;
                 }
             }

             // one does not equal two
             return false;
         }

         return true;
     }