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 bubble(string message, msgtype messagetype)
         {
             InitializeComponent();

             // Set the text in the bubble from the message in the parameter.
             lblmessage.Text = message;

             // Change Color based on Message type.
             if (messagetype.ToString() == "In")
             {
                 // incoming User message
                 this.BackColor = Color.Gray;
             }
             else
             {
                 // Outgoing Bot Message
                 this.BackColor = Color.FromArgb(0, 164, 147);
             }
             Setheight();
         }