KBD

Keith Devens .com

Saturday, September 6, 2008 Flag waving
Whereof one cannot speak, thereof one must be silent. – Ludwig Wittgenstein (Tractatus Logico-Philosophicus)
← Weblog posting bookmarkletJavascript toggle functions →

Daily link icon Thursday, July 12, 2007

The annoying way to .clone() a list in C#

List<Type> temp = list.ConvertAll<Type>(delegate(Type a){return a;});

You'd think a generic type like List would have a useful clone or copy method, but noo. (Type is just a placeholder... insert your type here)

← Weblog posting bookmarkletJavascript toggle functions →

Comments XML gif

Arif Eqbal wrote:

It Does not actually Clone??
It Copies, If you change a value for the list the temp objects member also changes.

∴ Arif Eqbal | 22-Aug-2007 7:29am est | #10270

Keith (http://keithdevens.com/) wrote:

Yeah, it's just a shallow copy.

Keith | 22-Aug-2007 9:25am est | http://keithdevens.com/ | #10271

Feel free to post a comment below. Please see my comment policy.

Formatting Rules (No HTML):

  • **bold**, *italic*, _underlined_, --strikeout--
  • "text"="url" creates a link, and URLs are auto-highlighted
  • Blockquote: Like e-mail, begin paragraph with > (greater-than sign)
  • Lists: begin paragraph with *,-, or + (unordered), or # (ordered)
  • Code block: ?!code:language=perl|php|sql|javascript|etc.{\n}...{\n}?!/code

:
(will be your IP address if blank)
: (optional)
(Will not be shown on site)

: (optional)
:

September 2008
SunMonTueWedThuFriSat
 123456
78910111213
14151617181920
21222324252627
282930 



RSS feed RSS feed for Keith's Weblog
Atom feed Atom feed for Keith's Weblog
Weblog archive
Recent comments
  on 6 posts

Recent comments XML

new⇒I hate Norton Antivirus

Norton internet secerity is bundled​with everything from a sausage roll​to ...

kevin sands: Sep 6, 7:23pm

new⇒I hate ASP.NET

CF, why pick that piece of trash?​Cold Confusion. Is it finally​really a OO...

ColdConfusion: Sep 5, 8:36pm

Maps of Iraq

This is for Linda, I will be​visiting that site some time in the​near futur...

Bob: Sep 5, 1:20pm

Girls, please don't get breast implants

Well alright I just read my above​comment and I wanted to add​this...I shou...

76.66.140.8: Sep 4, 7:31pm

Spider solitaire

I don't think the question was​necessarily if there are unbeatable​games.  ...

Jared: Sep 4, 12:44pm

Convert Pantone Colors to RGB and Hex - Color Conversion Chart

The colors on those website don't​seem to relate to the pantone data​we hav...

blah: Sep 3, 10:12am

Generated in about 0.199s.

(Used 8 db queries)

mobile phone