Browsing 7239 questions and answers with Jon Skeet
Use the NumberFormatInfo via CultureInfo.NumberFormat and there are various currency-related properties, including CurrencyDecimalSeparator and CurrencyPositivePattern. It looks like you want a positive pattern of 1 - you'll have to look... more 12/6/2013 2:49:50 PM
The compiler doesn't know that you can multiply and add T values - it's not the return part which the problem, it's the expression itself. You'll see the same effect if you split the two parts: T result = a + b; return result; It will... more 12/6/2013 1:53:17 PM
The error occurs at the 4th line, "result.add(word.substring(1));" Then word must be null. result clearly isn't. You should look at what's calling this code, and work out why it's passing in a null reference. You might also want to... more 12/6/2013 7:10:24 AM
I found your question hard to follow, but I suspect the simplest approach is just to use else: if (...) { data.s = "For approval MM"; } else if (...) { data.s = "For approval MP"; } else if (...) { data.s = "For approval... more 12/6/2013 7:04:54 AM
If it's the "how do I remove an element from an ArrayList<>" part which is causing problems, and you want to check all the values, you probably want to use an Iterator and call remove on that: for (Iterator<String> iterator =... more 12/6/2013 6:49:44 AM
Random isn't thread-safe. You should use a different instance of Random for each thread, instead. I wouldn't suggest locking as you've suggested, as otherwise if that's a significant part of your overall time, it could end up being no... more 12/5/2013 10:31:08 PM
I mean "which dynamic operation?" The one that invokes a method using a dynamic variable as the argument. Note that the type dateStrFromDynamic will still be dynamic - the compiler doesn't know that ToString() will definitely return... more 12/5/2013 7:54:05 PM
Question: why should it be illegal to cast a short to a long? You're trying to cast a boxed short to a long. You can see this without a database: int x = 10; object o = x; long y = (long) o; // Bang! If you cast to the right type... more 12/5/2013 5:21:46 PM
You need X as the specifier for the UTC offset as it's in ISO-8601 format, as per the SimpleDateFormat documentation. new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ssX") more 12/5/2013 2:42:58 PM
From RFC 2732: To use a literal IPv6 address in a URL, the literal address should be enclosed in "[" and "]" characters. For example, this works fine: var uri = new Uri("ftp://[1111:2222:3333::43]/testing/1kb.zip"); If you... more 12/5/2013 2:37:48 PM