Browsing 7239 questions and answers with Jon Skeet
The problem is that you're declaring the module variable in a nested scope, but then trying to use it outside that scope: while (...) { if (...) { Module module = ...; } } return module; What would you expect to happen... more 3/18/2015 2:34:43 PM
I don't see any benefit in the first approach. I'd just use LINQ to find the items though: foreach (var entry in dictionary.Where(e => e.Value == "A")) { string ignored; // Do you actually need to check the return value? ... more 3/18/2015 2:23:08 PM
It sounds like you really just want to use JArray to wrap the array: something["numbers"] = new JArray(a); In other words, let Json.NET take care of the textual representation - you just need to tell it the logical value, which is just... more 3/18/2015 7:20:13 AM
Well, you're getting the compiler error because - as it says - the properties of anonymous types are read-only in C#. More fundamentally, even if you could modify them, you'd have to expect LINQ to SQL to reverse whatever you put into... more 3/18/2015 7:02:58 AM
Yes, that's absolutely possible, in exactly the same way as you pass any other variable by reference: using System; class Test { static void Main(string[] args) { int[] values = new int[10]; Foo(ref values[0]); ... more 3/17/2015 7:34:34 PM
Well, two options: Move the declaration to before the if statement, and give it an explicit type: IQueryable<Auction> auctionData; if (...) { ... } else { ... } Change the structure to only have a single declaration, e.g.... more 3/17/2015 7:10:22 PM
One option would be to have an enum where you've currently got int arrays: public enum Field { ID(0, 10), NAME(15, 45); private final int start; private final int end; private Field(int start, int end) { ... more 3/17/2015 5:15:33 PM
Well you're not actually using df at all. You need to pass the result of calling monthlyPayment() and totalPayment() to the format method. For example: Mortgage mortgage1 = new Mortgage(annualInterestRate, numOfYears,... more 3/17/2015 5:03:58 PM
No, you can't do that. I suggest you write your own separate class, given that you want different functionality. Obviously Java allows you to override non-final instance methods in classes, but even then the clients would need to know to... more 3/17/2015 1:57:43 PM
While the "read to the closing tag" sounds appealing, you'd need to have a parser which didn't end up buffering all the data. I would read all the data into a byte[], then search for the separator there - then you can split the binary... more 3/17/2015 12:56:29 PM