Generic method to get ASP.NET not checked items in checkbox list or radiobutton list?
<p>I have a method to get what items are not checked in a checkbox list like so:</p>

<pre><code>public static string[] GetNotSelectedCheckboxes(CheckBoxList list)
{
    ArrayList values = new ArrayList();
    for (int counter = 0; counter &lt; list.Items.Count; counter++)
    {
        if (!list.Items[counter].Selected)
        {
            values.Add(list.Items[counter].Value);
        }
    }
    return (String[])values.ToArray(typeof(string));
}
</code></pre>

<p>I now have a requirement to get not selected items in a radiobutton list, I copied the same method and instead of having a <code>CheckBoxList</code> as parameter I have a <code>RadioButtonList</code>.</p>

<pre><code>public static string[] GetNotSelectedRadioButtons(RadioButtonList list)
{
    ArrayList values = new ArrayList();
    for (int counter = 0; counter &lt; list.Items.Count; counter++)
    {
        if (!list.Items[counter].Selected)
        {
            values.Add(list.Items[counter].Value);
        }
    }
    return (String[])values.ToArray(typeof(string));
}
</code></pre>

<p>Now the code does exactly the same thing and I read a bit about generic methods, is this where I should use one? I had a look at it but didn't get the syntax right and I'm not sure how to use <strong>list.Items</strong> if I don't specifically specify it as a radio or checkbox list.</p>

<p>Should I use a generic method here and any input on how I should go on about it?</p>

<p>Thanks in advance.</p>
