enumerator

c# - how to create an array from an enumerator

In C#, what's the most elegant way to create an array of objects, from an enumerator of objects? e.g. in this case I have an enumerator that can return byte's, so I want to convert this to byte[]. EDIT: Code that creates the enumerator: IEnumerator<byte> enumurator = updDnsPacket.GetEnumerator(); ...

Ruby generators vs Python generators

Hi, I've been researching the similarities/differences between Ruby and Python generators (known as Enumerators in Ruby), and so far as i can tell they're pretty much equivalent. However one difference i've noticed is that Python Generators support a close() method whereas Ruby Generators do not. From the Python docs the close() meth...

What's Enumerator in an object?

This line of code confuses me: List<string> keys = new List<string>(); IDictionaryEnumerator ca = cache.GetEnumerator(); while (ca.MoveNext()) { keys.Add(ca.Key.ToString()); } What is an Enumerator? Is it connected to Enumerations? I try to find a tutorial on enumerators, but without success. Hope someone will have patience to expla...

How can I list all the const properties defined in a class

How can i list all the names (and values) of public (and private / protected) const defined in a class ? public class Layers { public const BACKGROUND:String = "background"; public const PARENT:String = "parent"; public const MAP:String = "map"; public const LINES:String = "lines"; public const POINTS:String = "poin...