Browsing 7239 questions and answers with Jon Skeet
It's not the variable declarations - it's the code you're using to initialize them. I wouldn't be at all surprised to find that GetLineFromCharIndex and GetFirstCharIndexFromLine were expensive - and currently you're calling the Lines... more 5/23/2015 7:39:56 PM
It's not clear exactly what's actually sending the file, but it's being transmitted as base64 - which is why it's 4/3 the size of the original. I'm pretty sure if you run the received file through a base64 decoder you'll get the original... more 5/23/2015 7:36:56 PM
This is a matter of LINQ's lazy evaluation. Each time you iterate over list in GetBool1(), you're creating a new sequence of values. Changing the Value property in one of those objects doesn't change anything else. Compare that with... more 5/23/2015 1:50:52 PM
You're never initializing your student field, so it's null. You could use: // Note: public fields are almost *always* a bad idea private readonly Student[] students; public University(int numberOfStudents) { students = new... more 5/23/2015 1:23:16 PM
It really depends on what you want to achieve. If you're happy to create a copy of the list, then I'd just use something like: public List<Fruit> getFruits() { return new ArrayList<>(allBananas()); } That's now... more 5/23/2015 9:20:12 AM
You're creating an empty ArrayList, and then trying to get the third element (element at index 2) from it within your push method. That's not going to work. Now, you're currently ignoring your initSize parameter in your constructor. You... more 5/23/2015 8:58:00 AM
The problem is that you're abusing the threading model. You shouldn't be accessing UI components in a thread other than the UI thread - and having a tight loop like this is pretty much always a bad idea. You should read about the Swing... more 5/23/2015 8:55:22 AM
It sounds like you probably want something like: Dictionary<string, Func<string[], int>> functions = ...; This is assuming the function returns an int (you haven't specified). So you'd call it like this: int result =... more 5/22/2015 1:26:00 PM
The precedence here just means that X || Y && Z is equivalent to: X || (Y && Z) That executes as: Evaluate X If X is true, the result is true Otherwise, evaluate Y If Y is false, the result of Y && Z is... more 5/22/2015 12:31:32 PM
It looks like DoSomething(List<Foo> foos) only actually needs to iterate over the list. So you can change it to: public void DoSomething(IEnumerable<Foo> foos) { // Body as before } Now you can pass in a List<Bar>... more 5/22/2015 12:22:02 PM