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:

         protected bool OpSetPropertiesOfActor(int actorNr, Hashtable actorProperties, bool broadcast, byte channelId)
         {
             if (this.DebugOut >= DebugLevel.INFO)
             {
                 this.Listener.DebugReturn(DebugLevel.INFO, "OpSetPropertiesOfActor()");
             }

             if (actorNr <= 0 || actorProperties == null)
             {
                 if (this.DebugOut >= DebugLevel.INFO)
                 {
                     this.Listener.DebugReturn(DebugLevel.INFO, "OpSetPropertiesOfActor not sent. ActorNr must be > 0 and actorProperties != null.");
                 }
                 return false;
             }

             Dictionary opParameters = new Dictionary();
             opParameters.Add(ParameterCode.Properties, actorProperties);
             opParameters.Add(ParameterCode.ActorNr, actorNr);
             if (broadcast)
             {
                 opParameters.Add(ParameterCode.Broadcast, broadcast);
             }

             return this.OpCustom((byte)OperationCode.SetProperties, opParameters, broadcast, channelId);
         }