enumeration

Why am I getting a 0x8000500c error when enumerating a SearchResultCollection in .Net

孤者浪人 提交于 2019-12-11 11:07:57
问题 I am trying to enumerate the values in a SearchResultCollection. Everything compiles fine, but I get the 0x8000500c error on this line: foreach (PropertyValueCollection e in de.Properties.Values) { sw.WriteLine(e.Value); } Full method is below: private static void GetValues() { var directoryEntry = new DirectoryEntry("LDAP://8.8.8.8:8888", "foo", "bar", AuthenticationTypes.None); var ds = new DirectorySearcher(directoryEntry); var final = ds.FindAll(); var sw = new StreamWriter(@"C:\z\FooBar

how to enumerate all the div tag with same id?

孤者浪人 提交于 2019-12-11 11:06:40
问题 I have web-pages based on widget and I have given all the div the same ID attribute. After the page is loaded, I want to enumerate all the div element which matches the ID element 'widget'. I am using jQuery . Then I want to get the internal div attribute within the 'widget' div which shall be used as a tooltip. <div id="widget" class="span-8 " > <h2><a href="">Example.com</a></h2> <ul> <li><h3><a href="example.com">Example News 1</a></h3> <div id="tooltip-content"> <div class="published">Thu

Enumerate NSArray starting at givven index searching both ways (wrap around)

房东的猫 提交于 2019-12-11 10:32:47
问题 Example. I've got an array with 15 objects. I want to start enumerating from a given index. Say start at index 5 and then the index above, the index under, above, under etc... I do want it to wrap around. So the order of indexes in my example would be. 5, 6, 4, 7, 3, 8, 2, 9, 1, 10, 0, 11, 14, 12, 13 It would be great to have a method signature similar to following line, but I don't require that to approva an answer: - (void)enumerateFromIndex:(NSUInteger)index wrapAroundAndGoBothWays:(void (

__init__ being called on __str__ result in aenum.Enum

喜你入骨 提交于 2019-12-11 09:08:36
问题 While trying silly things to get my __str__ method working correctly on an Enum member, I discovered some behavior I don't really understand. I'm aware the following implementation is wrong, but I don't know why it does what it does. Consider the following class: from aenum import Enum, AutoValue class MyEnum(str, Enum, settings=AutoValue, init="value data1 data2"): __str__ = lambda self: self def __new__(cls, name, *args, **kwargs): member = str.__new__(cls) member._value_ = name return

Expected ';' in 'for' statement specifier (iOS)

不打扰是莪最后的温柔 提交于 2019-12-11 06:22:27
问题 when I try the following code in iOS for fast enumeration... NSArray *array = [NSArray arrayWithObjects: @"Hefeweizen", @"IPA", @"Pilsner", @"Stout", nil]; for (NSString *element in array) NSLog(@"Beer: %@", element); ... I get this error: Expected ';' in 'for' statement specifier Do you know what is wrong? 回答1: That syntax is called fast enumeration and is part of Objective-C 2.0, so if you're running a pre-2.0 version of the compiler it won't work. The standard syntax which it sounds like

Add elements to a list while iterating over it

你说的曾经没有我的故事 提交于 2019-12-11 05:56:35
问题 I'm trying to add new elements to a list of lists while iterating over it List<List<String>> sets = new List<List<string>>(); foreach (List<String> list in sets) { foreach (String c in X) { List<String> newSet = ir_a(list, c, productions); if (newSet.Count > 0) { sets.Add(newSet); } } } The error I get after a few loops is this: Collection was modified; enumeration operation may not execute I know the error is caused by modifying the list, so my question is: What's the best or most fancy way

Creating a Vector Class object in Java

僤鯓⒐⒋嵵緔 提交于 2019-12-11 05:53:16
问题 The Problem with this is it gives me an error message saying The type Vector is not generic; it cannot be parameterized with arguments . However I need the argument types. Keep in mind that I'm new to java. package day7; import java.util.*; public class Vector { public static void main(String args[]) { //Vector //vec //Vector throws the error. public Vector<String> vec = new Vector<String>(50); Vector v = new Vector(); //Adding elements to a vector vec.addElement("Apple"); vec.addElement(

Enumerations vs int flags?

本小妞迷上赌 提交于 2019-12-11 04:21:13
问题 Just wanted some opinions on the matter. I have always used int flags, and was just curious on possible performance of ease of use if I were to use enumerations in Java? 回答1: I very much doubt you'd see performance benefits - and in some cases there may even be performance penalties, depending on how you're using them. I doubt they'd be significant though. The benefit isn't in terms of performance - it's in terms or expressing your intentions more clearly, leading to more readable (and type

How to enumerate all member variables of a class / struct in c++

我只是一个虾纸丫 提交于 2019-12-11 04:17:13
问题 I'm working on some kind of simple reflection for c++ structs where i want to recursivly iterate over all member variables. The code below almost does what i want but my compiler complians: "recursive type or function dependency context too complex" coming form aggregate_arity<MemberType>::size() which is based on Orients aggregate_arity implementation. Example usage case: struct B { SPVStruct; var_t<float2_t, true> f4; }; struct A { SPVStruct; var_t<float2_t, true> f2; var_t<float3_t, true>

Multiple Checkboxes and enumeration

若如初见. 提交于 2019-12-11 04:12:45
问题 I am having troubles getting my head wrapped around how this should be done. I have 3 check boxes on a form that are to be input into a constructor. I am creating a variable to pass this information into the constructor. Listed below some of the code public enum Accessories { None, StereoSystem, LeatherInterior, StereoAndLeather, ComputerNavigation, StereoAndNavigation, LeatherAndNavigation, All } SalesQuote.Accessories accessoryChosen; if(!chkStereoSystem.Checked && !chkLeatherInterior