Browsing 7239 questions and answers with Jon Skeet
The underlying problem here is your use of Duration to start with, IMO. A Duration is just a number of milliseconds... it's somewhat troublesome to consider the number of years in that, as a year is either 365 or 366 days (and even that... more 9/20/2016 7:29:36 AM
JObject.Parse takes a string, not a Stream. You're trying to pass it response, which is a Stream. To fix it, just use HttpClient.GetStringAsync instead, e.g. using (HttpClient client = new HttpClient()) { var response =... more 9/20/2016 7:21:50 AM
Your Speed property is the problem. Here's the code: public int Speed //access private int speed { get { return speed; } set { speed = Speed; } } The getter is fine - it returns the value of the private variable. The setter,... more 9/19/2016 2:56:43 PM
Note: I believe fabian's solution is superior to this, but I've kept it around to demonstrate that there are many different ways of implementing this... I would probably: Create a new type which contained the distance from the outlet as... more 9/19/2016 6:32:15 AM
There are two reasonably simple options: Construct a date using that number as the month, and then format it with a custom format, e.g. DateTime date = new DateTime(2000, month, 1); string monthName = date.ToString("MMMM"); Use... more 9/18/2016 3:46:46 PM
This is the problem: public int compareTo(Object other) You've said you can compare this object to any other object. You can't call other.getMidi(), because getMidi() isn't a method declared on Object. I would suggest you change your... more 9/16/2016 9:27:06 PM
I cannot mock now() because it is static Indeed - but fortunately, you don't have to. Instead, consider "a date/time provider" as a dependency, and inject that as normal. java.time provides just such a dependency: java.time.Clock. In... more 9/16/2016 9:19:20 AM
Sounds like you want to provide the culture en-PHI... although that isn't a valid culture name apparently. Perhaps you just want phi as the language? var culture = CultureInfo.GetCultureInfo("phi"); var text = string.Format(culture, "The... more 9/16/2016 8:20:29 AM
You can't. You've already lost all the important data. Calling toString() on a byte[] doesn't give you anything useful, because arrays in Java don't override toString()... so you're getting the implementation from Object, which just... more 9/16/2016 7:46:26 AM
You can provide your own JsonConverter even for numeric types. I've just tried this and it works - it's quick and dirty, and you almost certainly want to extend it to support other numeric types (long, float, double, decimal etc) but it... more 9/16/2016 7:40:08 AM