Browsing 7239 questions and answers with Jon Skeet
Just use string.Format, with a precision specifier saying how many digits you want: string name = string.Format("tail{0:d6}.jpg", index); See the MSDN documentation for standard numeric string formats for more details. You can build... more 11/12/2014 7:47:06 AM
I've reproduced this - it looks like it's simply a bug in Mono. It's very easily demonstrated: decimal x = 9m; decimal y = x / 10; Console.WriteLine(y); This should be "0.9", but it's actually "0.9000000000000000000000000000". Please... more 11/12/2014 7:22:26 AM
I would expect the compiler to know that type T is any IComparable type... Yes, it knows that - but your Bar constructor is expecting a Foo(Of IComparable) not a Foo(Of T) where T implements IComparable. You want generic covariance,... more 11/11/2014 6:20:11 PM
Just get rid of the first line entirely: var response = new GetMyCollection().GetCollection(request); Assert.Greater(response.MyCount, 0); If new GetMyCollection().GetCollection(request) throws an exception, that will make the test fail... more 11/11/2014 6:05:07 PM
Closeable is restricted to throw IOException, which may not be appropriate for some closeable but non-IO-bound resources. AutoCloseable is declared to throw Exception, making it more general-purpose. The API for Closeable can't be... more 11/11/2014 1:48:52 PM
Calendar.YEAR is just a constant saying which logical field you want to set within the calendar. The aim was to avoid having an API with setYear setDay setMonth ... In retrospect, I'd say this was a spectacularly bad idea - along with... more 11/11/2014 10:44:46 AM
You're currently converting the value to a string but then comparing it with an int. Don't do that - it's not going to work :) It's probably simplest to convert it to an int instead: var Activites = (from e in... more 11/11/2014 9:18:08 AM
Personally, I find that very hard to read, as well as invalid (it won't compile) - because you're trying to use the conditional operator as a statement expression, when it's not. Personally, I'd write something like: for (int i = 0; i... more 11/10/2014 7:23:10 PM
The problem is almost certainly not in ElementValueNull... it's that one of the earlier Element calls is returning null. You're calling an instance method (XContainer.Element()) and that's a perfectly ordinary instance method - if it's... more 11/10/2014 7:11:39 PM
Assuming you're using org.json.JSONObject, you can use the fact that JSONObject.put returns the value it's called on. For example: JSONObject x = new JSONObject().put("c", new JSONObject().put("a", "b")); You might want to consider... more 11/10/2014 5:12:37 PM