Re: Array.Clear vs List<>.Clear
- From: Lee Crabtree <lcrabtree@xxxxxxxxx>
- Date: Thu, 04 Oct 2007 10:36:52 -0500
That's more or less what I wound up doing anyway, but curiosity got the better of me, and there's rarely harm in asking.
Lee Crabtree
Nicholas Paldino [.NET/C# MVP] wrote:
Lee,.
There isn't a mechanism to do this, but writing your own is easy:
public static void ClearList<T>(List<T> list, int index, int length)
{
// Cycle through the list and set the item to the default.
for (; index < (index + length); ++index)
{
// Set the item in the list to the default value.
list[index] = default(T);
}
}
- References:
- Array.Clear vs List<>.Clear
- From: Lee Crabtree
- Re: Array.Clear vs List<>.Clear
- From: Nicholas Paldino [.NET/C# MVP]
- Array.Clear vs List<>.Clear
- Prev by Date: Re: Ideas for a C# development project?
- Next by Date: Datagridview Combobox events
- Previous by thread: Re: Array.Clear vs List<>.Clear
- Next by thread: Re: Array.Clear vs List<>.Clear
- Index(es):