Browsing 7239 questions and answers with Jon Skeet
Yes, absolutely - copying a collection of immutable objects is effectively deep, unless you do something crazy like synchronizing on the references or comparing them for reference equality (i.e. operations which depend on object identity). more 12/3/2013 8:48:23 PM
Well presumably the statement: xmlModifier.setMacro(tempdoc, liquidity, "liquidity"); has some effect on xmlModifier, or tempdoc, or liquidity - so with that commented out, you don't see that effect. My guess is that the method... more 12/3/2013 6:37:30 PM
If you use a lambda expression which doesn't capture anything, the compiler will generate a static field to cache it in. So use that, you can change the Action to an Action<YourClass> and call it with this. So: class YourClass { ... more 12/3/2013 6:29:59 PM
If you want each object to be distinct (so not equal to any other object) then just don't override Equals and GetHashCode at all. The default is to give a "probably unique" hash code, which is all you need to narrow the choices down - and... more 12/3/2013 12:10:40 PM
Well Random.nextFloat gives a value greater than or equal to 0, and less than 1 - i.e. a range of [0, 1). So to map that to a range of [-1, 1) you just need to multiply by 2 and subtract 1. float value = random.nextFloat() * 2 - 1; In... more 12/3/2013 7:21:13 AM
This line: static Player[] players = new Player[amountofPlayers]; is executing before you assign a value to amountOfPlayers based on the user input. So amountOfPlayers has its default value of 0, and you're creating an array of 0... more 12/3/2013 6:49:41 AM
I have a method that is used in the wrong scenario (it's basic assumption doesn't hold). That sounds like an exact match for IllegalStateException: Signals that a method has been invoked at an illegal or inappropriate... more 12/2/2013 10:30:09 PM
Given that your second snippet works, I strongly suspect that for the first snippet the encoding you're using in your editor isn't the same as the encoding your Groovy interpreter/compiler is using. In other words, the problem isn't in... more 12/2/2013 8:58:56 PM
I suspect you aren't actually running Form1_Load. Here's a short but complete program to demonstrate the exception being thrown as expected: using System; using System.Collections.Generic; using System.Windows.Forms; class Test { ... more 12/2/2013 8:50:58 PM
Okay, I think I now understand it. While the C# spec doesn't call this out, it doesn't actually mention InternalsVisibleTo at all. I think the way to understand it is that you can't change the acceptable set of call sites for a member by... more 12/2/2013 8:29:55 PM