Browsing 7239 questions and answers with Jon Skeet
Basically, the expression on the RHS of the = is resolved and evaluated as it would be in any other context. So you could have: ChuckNorris chuck1 = new ChuckNorris { Impact = "foo" }; ChuckNorris chuck2 = new ChuckNorris { Impact =... more 5/10/2015 2:54:51 PM
This is the problem: for (int i = 1; i <= BUTTON_COUNT; i++) Arrays in Java are 0-indexed. So while you're using array indexes 1 to 8, the valid indexes are actually 0 to 7. So your loop should be: for (int i = 0; i <... more 5/10/2015 8:16:35 AM
Well, you can get all elements using the Descendants() method: foreach (var element in xdoc.Descendants()) { Console.WriteLine(element.Name); } However, that won't do any indentation. If you want indentation as well, you could use... more 5/10/2015 6:49:00 AM
I would handle this in three steps: Find all elements in a but not b Find all elements in b but not a Add those two sets together So for example: Set<String> aSet = new HashSet<>(Arrays.asList(a)); Set<String> bSet =... more 5/10/2015 6:35:49 AM
The method for doing this is non-static, as the date2 int changes. I think you've misunderstood the meaning of the static modifier. Your method doesn't use any instance fields, and there's no reason to override it in subclasses, so... more 5/9/2015 7:52:11 PM
That sounds like you just need an appropriate LINQ transformations: results = results .GroupBy(p => p.ProductCode) .Select(g => new Product { ProductCode = g.Key, Name = g.First().Name, Type =... more 5/8/2015 1:58:35 PM
To keep this simplified in coding, I put a "ShowDialog()" call at the end of the constructor of the form being displayed. That sounds like an ugly design to me, personally. Constructors are designed to return a usable object - and... more 5/8/2015 1:05:12 PM
From what I understand, that syntax isn't "normal" C# Yes it is, as of C# 3. so the above line wouldn't have any meaning if I hadn't included System.Linq Yes it would. It would still have effectively been transformed by the... more 5/8/2015 12:45:22 PM
Well you could just call the normal iterator() method, then call next() that many times: public Iterator<E> iterator(int index) { Iterator<E> iterator = iterator(); for (int i = 0; i < index &&... more 5/8/2015 12:35:51 PM
Three options: Use a switch statement, assuming you're using Java 7 or 8: switch (getLetter()) { case "A": case "O": case "I": case "B": ... value = "1"; ... } Use three Set<String> objects (Best,... more 5/8/2015 11:26:31 AM