Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>What you need is a Set, as far as I remember there was no Set implementation in 2.0. You can check <a href="http://www.codeproject.com/KB/recipes/sets.aspx?msg=1297493" rel="nofollow noreferrer">this</a> out.</p> <p><strong>Edit:</strong> If you really want to implement your own, something like this would do the job in expense of performance on inserts: (I did not test the functionality)</p> <pre><code>class UniqueList&lt;T&gt; : IList&lt;T&gt; { private IList&lt;T&gt; m_InternalList; public UniqueList(IList&lt;T&gt; list) { m_InternalList = list; } public System.Collections.ObjectModel.ReadOnlyCollection&lt;T&gt; AsReadOnly() { return new System.Collections.ObjectModel.ReadOnlyCollection&lt;T&gt;(this); } #region IList&lt;T&gt; Members public int IndexOf(T item) { return m_InternalList.IndexOf(item); } public void Insert(int index, T item) { if (!m_InternalList.Contains(item)) m_InternalList.Insert(index, item); } public void RemoveAt(int index) { m_InternalList.RemoveAt(index); } public T this[int index] { get { return m_InternalList[index]; } set { if (!m_InternalList.Contains(value)) m_InternalList[index] = value; } } #endregion #region ICollection&lt;T&gt; Members public void Add(T item) { if (!m_InternalList.Contains(item)) m_InternalList.Add(item); } public void Clear() { m_InternalList.Clear(); } public bool Contains(T item) { return m_InternalList.Contains(item); } public void CopyTo(T[] array, int arrayIndex) { m_InternalList.CopyTo(array, arrayIndex); } public int Count { get { return m_InternalList.Count; } } public bool IsReadOnly { get { return m_InternalList.IsReadOnly; } } public bool Remove(T item) { return m_InternalList.Remove(item); } #endregion #region IEnumerable&lt;T&gt; Members public IEnumerator&lt;T&gt; GetEnumerator() { return m_InternalList.GetEnumerator(); } #endregion #region IEnumerable Members System.Collections.IEnumerator System.Collections.IEnumerable.GetEnumerator() { return m_InternalList.GetEnumerator(); } #endregion } </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload