Browsing 7239 questions and answers with Jon Skeet
I suspect this is the immediate problem: (q => o) => new { ... } I suspect you meant: (q, o) => new { ... } In other words, "here's a function taking a query and an order, and returning an anonymous type". The first syntax... more 10/24/2013 2:10:26 PM
Well you can use ildasm to see what the compiler has optimized for yourself. But if you were expecting it to remove the code entirely, it can't - because those three method calls could throw exceptions or modify state. So the best it could... more 10/24/2013 1:48:24 PM
You could either specify a name for the count, e.g. return jdbc.query("select pest_name, count(pest_name) as pest_count from sighting group by pest_name", new RowMapper<Sighting>() { public Sighting mapRow(ResultSet rs, int... more 10/24/2013 1:34:27 PM
You're using XDocument.Load(string), which accepts a filename or URL to load the XML from: Parameters uri: A URI string that references the file to load into a new XDocument. You want XDocument.Parse(string), which accepts XML... more 10/24/2013 1:16:02 PM
You can absolutely do this - but you'll have problems if you try to call the extension method on something which is both a BsonValue and an IEnumerable<BsonValue>. For example: BsonArray array = ...; BsonValue top =... more 10/24/2013 7:42:28 AM
The value of the f variable is a reference. That can be a null reference, or a reference to any object which "is a fish". As a Tuna object is a Fish object, it's fine to copy the value from t, which must either be a null reference or a... more 10/24/2013 6:33:34 AM
Firstly, splitting a large file into buffers that small will be incredibly wasteful of memory. The overhead for each object will be about the same size (or greater than) the data itself. However, the idea of splitting an input stream into... more 10/24/2013 6:20:37 AM
Is there a room for optimizing the existing code? Absolutely. The first place I'd change has nothing to do with how you load the XML - it's string concatenation. I'd change your recursiveOperation method to: private static string... more 10/24/2013 6:05:56 AM
The return value is evaluated first, then the finally block executes, then control is passed back to the caller (with the return value). This ordering is important if the expression for the return value would be changed by the finally... more 10/23/2013 9:29:05 PM
I would suggest you do exactly as per your second code snippet, but keep an array for these newly created objects - populate them in the loop, and access them in the second. void Method() { var intermediates = new Intermediate[100]; ... more 10/23/2013 9:19:51 PM