title: Refactoring big switch case to set property
body: <p>Hello, guys this is my first question I hope it is good \o/</p>
  
  <p>So, first of all it is c# application that keeps receiving data over a socket, the first time a connect to the server and I make a request I receive this big string (with more than 100 fields), for the sake of the example I will make it smaller: </p>
  
  <pre><code>0:7:1:Augusto:2:Question:3:Stackoverflow:4:Question:5:201609262219:6:stuff:7:stuff:..:100:!
  </code></pre>
  
  <p>And after that I receive this big string, I will only receive updates, for example:</p>
  
  <pre><code>0:7:3:Changed Topic:4:Doubt:5:2016092710:100:!
  </code></pre>
  
  <p>The field 100 will always come because it define the string terminator.<br>
  When I receive this big string I have to build a object Question, this big string will always result on a Question object, so we have:</p>
  
  <pre><code>public class Question 
  {
      public string Id { get; set; }
      public string Name { get; set; }
      public string Action { get; set; }
      public string Topic { get; set; }
      public string Body { get; set; }
      public string Time { get; set; }
      ...
      public string 99 { get; set; }
  }
  </code></pre>
  
  <p>To build  the question object I did this:</p>
  
  <pre><code>public void Process(string data) 
  {
      Question question = new Question();
      String[] fields = data.split(“:”);
  
      for(int i = 0; i &lt; fields.Length; i +=2) {
          Switch (fields[i]) {
              case "0":
                  question.Id = fields[i+1]
                      break;
  
              case "1":
                  question.Name = fields[i+1]
                      break;
  
              case "2":
                  question.Action = fields[i+1]
                      break;
              case "3":
                  question.Topic = fields[i+1]
                      break;
  
              case "4":
                  question.Body = fields[i+1]
                      break;
              case "5":
                  question.Time = fields[i+1]
                      break;
                  ...
              case "99":
                      Question.99 = fields[i+1]
                          break;
  
          }   
      }
  }
  </code></pre>
  
  <p>I researched through the stackoverflow answers, but they were different from what I am trying to achieve.<br>
  I do not think it is worth it using a strategy pattern or the command pattern because the logic is simply, and using this patterns will add too much complexity.<br>
  I am not sure if a <code>Dictionary&lt;string,Func&lt;string&gt;&gt;</code> will solve my problem, I think it will be the same thing as the witch case.<br>
  I also thought about using reflection (setValue) but i think it will be slow, and i really need this thing to fly.    </p>
  
  <p>The problem here is that I am just attributing a value to the object, and I do not want to make this big switch case. I think the way I am creating the object is some what wrong, but I cannot come to a different solution.  </p>
  
  <p>One more question, do you guys think the <code>string.Split()</code> will be a bottleneck on my code? Because I call the method Process(data) a bunch of time, like 100 times per second.</p>
  
  <p>Thanks!</p>
  
  <p>--- Update<br>
  Fixed sample and case "5".</p>