Browsing 7239 questions and answers with Jon Skeet
I now need to iterate through the values but keep the order in which the enum was passed to the methods. There's no such concept. The | operator doesn't have any way of preserving ordering. To put it another way, imagine we... more 10/31/2014 2:07:54 PM
You've currently declared questionid as a local variable in the onCreate method. That variable only exists for the duration of that method call. You want an instance variable - i.e. something which is part of the state of the object, and... more 10/31/2014 11:11:24 AM
No, there's no way of doing that. You could have a static variable in the class, to keep a reference to the "most recently created instance" available - this will prevent garbage collection, of course. Or you could make the class a... more 10/31/2014 10:19:07 AM
I'd probably use Objects.hash(bStr, super.hashCode()) You definitely want to combine the state you know about with the superclass implementation of hashCode(), so any solution would want to use bStr and super.hashCode()... your original... more 10/31/2014 9:05:05 AM
Simply put, += subscribe a handler to the event, and -= unsubscribes a handler from the event. (If the specified handler isn't an existing subscriber, the attempt is ignored.) Note that you can use significantly simpler syntax as of C#... more 10/31/2014 8:53:26 AM
How can I specify directly that I am trying to access a different class You could: Use the fully-qualified name, e.g. MyNamespace.Group x = new MyNamespace.Group(); Avoid adding a using directive for System.Text.RegularExpressions... more 10/31/2014 7:54:15 AM
You don't need to perform any string replacements - just use parameterized SQL and it should be fine. So you mustn't do this: // BAD CODE - DO NOT USE string sql = "INSERT INTO TABLE Person (ID, NAME) VALUES ('" + id + "', '" +... more 10/31/2014 7:28:26 AM
You're calling DataOutput.write(int) on the DataOutputStream, which is documented as: Writes to the output stream the eight low-order bits of the argument b. The 24 high-order bits of b are ignored. I suspect you really want... more 10/31/2014 7:24:48 AM
Yes, you're trying to access it in the wrong way. A constant isn't associated with an instance of a type - it's associated with the type itself. So you want: int x = Foo.type; Basically, const members are implicitly static, and C#... more 10/30/2014 11:21:41 PM
String.contains doesn't use regular expressions - it just checks whether one string contains another, in the way that "foobar" contains "oob". It sounds like you want to check that name only contains letters, in which case you should be... more 10/30/2014 10:59:01 PM