C abuse of the week [entries|reading|network|archive]
simont

[ userinfo | dreamwidth userinfo ]
[ archive | journal archive ]

Thu 2011-03-17 10:23
C abuse of the week
LinkReply
[personal profile] andrewduckerThu 2011-03-17 11:03
Yeah - this is much easier in C#, where all of the built in collection types support IEnumerable, and if you were creating a new collection type then not supporting IEnumerable would be a bit silly.

(And yes, I know that C# isn't suitable for all sorts of things.)
Link Reply to this | Parent | Thread
[personal profile] simontThu 2011-03-17 11:08
Does even the ordinary array type support IEnumerable too? (I presume that C# still has ordinary array types, and doesn't actually require you to instantiate a dynamically allocated collection object every time you want to store n things in a row.)
Link Reply to this | Parent | Thread
[personal profile] andrewduckerThu 2011-03-17 11:20
Yup. Array implements IEnumerable and IEnumerable<>. I think it does some jiggery-pokery under the covers to do so, but I've never dug into how they actually work. I would have suspected they were significantly slower than pure C++, but it seems that I am incorrect:
http://www.mightyware.com/cpp_vs_csharp_arrays.bhs
Link Reply to this | Parent
navigation
[ go | Previous Entry | Next Entry ]
[ add | to Memories ]