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 static int MaxMilliseconsPerPing = 800; // enter a value you're sure some server can beat (have a lower rtt)
     {
         get
         {
             Region result = null;
             int bestRtt = Int32.MaxValue;
             foreach (Region region in PhotonNetwork.networkingPeer.AvailableRegions)
             {
                 Debug.Log("BestRegion checks region: " + region);
                 if (region.Ping != 0 && region.Ping < bestRtt)
                 {
                     bestRtt = region.Ping;
                     result = region;
                 }
             }

             return (Region)result;
         }
     }