Browsing 7239 questions and answers with Jon Skeet
getObjectSize() is meant to give an approximation of the size of objects of the specified type. They aren't affected by static fields, because static fields exist on a per-type basis rather than a per-object basis. Add as many static... more 6/8/2017 8:46:03 AM
Given that you're querying count(*), you'd be better using ExecuteScalar rather than ExecuteReader(), for one thing. Next, the result will be an integer, which is why GetString() fails. Change it to: int count = (int)... more 6/8/2017 8:44:35 AM
You've just got a precedence problem. You've got: (int) x + y which is equivalent to ((int) x) + y ... which will then promote the result of the cast back to a float in order to perform floating point addition. Just make the cast... more 6/7/2017 1:42:49 PM
I would suggest not using DateTime at all. You're using Noda Time - so go all in :) To parse text as a ZonedDateTime, you use a ZonedDateTimePattern. Here's an example: using System; using NodaTime; using NodaTime.Text; class Program { ... more 6/7/2017 8:05:05 AM
You can't. There's no such contextual information in an int. An integer is just an integer. If you're talking about formatting, you could use something like: string formatted = value.ToString("0000"); ... that will ensure there are at... more 6/7/2017 6:33:22 AM
Your SQL would be something like SELECT * FROM Tokens WHERE token = someToken - that's treating someToken as a column name, not a value. You should use parameterized SQL instead of building the SQL dynamically, e.g. // Include the... more 6/6/2017 10:07:48 PM
CurrentCulture and CurrentUICulture are independent properties. You're only setting CurrentCulture, and you're reporting that everywhere except for 2a, which reports CurrentUICulture. If you use the same property consistently throughout... more 6/6/2017 2:35:28 PM
Mostly, that's just hard to read code. It would be at least slightly simpler to read (IMO) as a[dice.nextInt(6) + 1]++; ... but it's easier still to understand it if you split things up: int roll = dice.nextInt(6) +... more 6/6/2017 9:56:42 AM
Well you're using &&, which is short-circuiting... if int.TryParse(string1, out min) returns false, the second call to int.TryParse won't be made, so max isn't definitely assigned. You could write: if (int.TryParse(string1, out... more 6/6/2017 9:25:29 AM
As documented, CopyToDataTable() can't be called on an empty sequence of rows - presumably because then there's no schema information to include. Instead, if you know your original table is empty and you want a new table with the same... more 6/6/2017 7:14:41 AM