Re: Array.Clear vs List<>.Clear
- From: Marc Gravell <marc.gravell@xxxxxxxxx>
- Date: Thu, 04 Oct 2007 08:28:17 -0700
IMO, the Array.Clear() behavior is incorrect, as it doesn't follow the
normal intent of Clear(), and should throw a NotSupportedException. Re
the generic list - I can't think of many scenarios when I would *want*
to do this on a list - however, looping (using indexer, not foreach)
is a reasonable option and won't generally be too slow. You could
simply Clear() and AddRange(new T[count]), but this unnecessarily
creates the array.
Marc
.
- Follow-Ups:
- Re: Array.Clear vs List<>.Clear
- From: Marc Gravell
- Re: Array.Clear vs List<>.Clear
- References:
- Array.Clear vs List<>.Clear
- From: Lee Crabtree
- Array.Clear vs List<>.Clear
- Prev by Date: Re: Datagrid checkbox states
- Next by Date: Re: Array.Clear vs List<>.Clear
- Previous by thread: Array.Clear vs List<>.Clear
- Next by thread: Re: Array.Clear vs List<>.Clear
- Index(es):