title: C# class object overwrite
body: <p>I am new to OOP, so please take this into consideration. I am puting data that I get from this match into object of a class, but it is done in foreach loop so each time it is called, data inside my object are overwriten, and at the end I would like to have all data in my object. But I only have from last match. How should I do it to avoid this overwriting? Maybe I do it in completely wrong way? </p>
  
  <pre><code>foreach (var match in matches)
              {
                  dataTable.Rows.Add(new Group[] { match.Groups["C0"], match.Groups["C1"], match.Groups["C2"], match.Groups["C3"], match.Groups["C4"] });
  
                  MyClass sk = new MyClass();
  
                  sk.Category = match.Groups["C0"].ToString();
                  sk.Device = match.Groups["C1"].ToString();
                  sk.Data_Type = match.Groups["C2"].ToString();
                  sk.Value = match.Groups["C3"].ToString();
                  sk.Status = match.Groups["C4"].ToString();
              }
  </code></pre>