c# Memory performance and speedup
<p>i have a situation, i need to process an jagged array of 20k registers every time a user press a key. I have a grid and while the user is typing the system shows a filtered result in a grid. so. So i have a jagged array filled with all 20k registers. and the i have a list (global to the control) and it´s cleaned up every time the user press a key and filled up with just the filtered registers and then show then in the grid.</p>

<p>Here is the code</p>

<pre><code>the model
public struct PlayerLookUpAdapter
    {
        [Browsable(false)]
        public decimal Id { get; set; }
        [DisplayName("Número")]
        public String Number { get; set; }
        [DisplayName("Nombre")]
        public String Name { get; set; }
        [DisplayName("Apellido")]
        public String Surname { get; set; }
        [DisplayName("DNI")]
        public String Document { get; set; }
        [DisplayName("Estado")]
        public String Status { get; set; }
    }

private PlayerLookUpAdapter[] _source; // here are the 20k registers

List&lt;PlayerLookUpAdapter&gt; filteredOut = new List&lt;PlayerLookUpAdapter&gt;(); // here the filtered ones

// this code is executed every time the user press a key
private void tb_nro_KeyUp(object sender, KeyEventArgs e)
        {
            if (!(e.KeyCode.Equals(Keys.Enter) || e.KeyCode.Equals(Keys.Down)) &amp;&amp; _source!=null)
            {
                String text = tb_nro.Text.ToUpper();
                if (String.IsNullOrEmpty(text))
                {
                    fg.DataSource = _source;
                    fg.Refresh();
                    return;
                }
                fg.DataSource = null;
                filteredOut.Clear();
                int length = _source.Length;
                for (int i = 0; i &lt; length; i++)
                {
                    PlayerLookUpAdapter cur = _source[i];
                    if (cur.Number.ToUpper().StartsWith(text) || cur.Surname.ToUpper().StartsWith(text) || cur.Name.ToUpper().StartsWith(text))
                        filteredOut.Add(cur);
                }
                fg.DataSource = filteredOut;
                SetGridColumnsProperties();
                fg.Refresh();

            }
            else
            {
                fg.Focus();
            }
        }
</code></pre>

<p>is it a good solution in terms of memory usage and performance? have you got any advice? How can i gain more speed. It works realy good, but what about if i got 100k registers instead of 20k?</p>

<p>Thanks in advance.</p>
