Browsing 7239 questions and answers with Jon Skeet
I was expecting this to run in an infinite loop but it didn't. No, it wouldn't. Eventually the value will become 0 again. In particular, it will logically execute like this: 1 2 3 ... 2,147,483,646 2,147,483,647 -2,147,483,648 //... more 1/13/2014 6:59:32 AM
Casting to int always truncates towards 0. To round, you can use Math.round() instead. However, that always rounds halves up: class Test { public static void main(String[] args) { System.out.println(Math.round(-7.7)); // -8 ... more 1/12/2014 4:34:43 PM
At execution time, there's no such thing as dynamic really. However, the call to Convert.ChangeType is providing a dynamic value as an argument. Any method call using a dynamic argument is treated as having a return value of dynamic,... more 1/12/2014 1:43:27 PM
Your XML doesn't have any attributes. It has text within elements, but no attributes. If your XML had something like: <user name="foo" /> then it would give you an attribute. And you could have multiple attributes of... more 1/11/2014 11:23:25 PM
Yes, just set the Position property: MediaElement1.Position = TimeSpan.Zero; MediaElement1.Play(); more 1/11/2014 11:22:16 PM
Don't do it that way. Just don't. You can't get a useful age representation by subtracting one value from another - you'll find that the difference between two people who were born a day apart can differ massively based on exactly when... more 1/11/2014 5:46:48 PM
Just use DateTime.Ticks instead - there's absolutely no reason to start converting to and from strings here. long ticks = DateTime.Today.Ticks; // Later in the code when you need a DateTime again DateTime dateTime = new... more 1/11/2014 1:12:26 PM
I've come across exactly this problem in the last week. I strongly suspect that it is related to access tokens expiring or other errors: I've regularly seen this occur after my program has been active for 5 minutes (of polling every 20... more 1/11/2014 1:04:00 PM
It means "create a new instance of MemberClass, using enclosingInstance as the reference for the new instance". An inner class has an implicit reference to its enclosing class - normally if you just call new MemberClass() within an... more 1/11/2014 11:06:52 AM
How to parse the date, and keep formatting You need to keep the format alongside the DateTime if you want to. A DateTime does not have any concept of being in a particular format. The value of the DateTime returned by Parse isn't... more 1/10/2014 8:01:08 PM