Browsing 7239 questions and answers with Jon Skeet
Is that possible? Absolutely. For a start, it's very possible for a computer to do more than one thing in a millisecond. For a second thing, the clock consulted here often won't have a granularity of milliseconds - you may find that... more 12/11/2014 4:21:23 PM
It sounds like you want a regex of "at least one digit, then semi-colon and hash", with an anchor for "only at the start of the string": string author = Regex.Replace(m_Author, @"^\d+;#", ""); Or to make it more reusable: private... more 12/11/2014 1:50:42 PM
Why does the compiler even allow explicit casting no one is defined. What rules does the compiler apply here? It applies the lifted conversions defined in section 6.4.2 of the C# spec: Given a used-defined conversion operator that... more 12/11/2014 12:56:55 PM
Your fillData calls buffer.readLine(), which is declared to throw IOException - but you neither catch the exception witin fillData, nor declare that it might be thrown. The simplest fix is to change the signature of fillData to: public... more 12/11/2014 11:48:15 AM
Two reasons: You can only implement IEquatable<T> for your own types... whereas you can specify an IEqualityComparer<T> for any type, whether you can modify it yourself or not. There may be multiple ways of comparing a type... more 12/11/2014 11:44:28 AM
You can use anonymous functions pretty much anywhere, including field initializers - but for instance field initializers, you can't use this. So for example: public class Foo { private int x; private Func<int> y = () =>... more 12/11/2014 11:24:37 AM
Is there a suitable shorthand statement to increase an integer by an interval larger than 1, while storing the original variable, that I'm unaware of? No, there's no general compound post-increment operator. You could fake it with a... more 12/11/2014 10:45:59 AM
Well, it sounds like first you need to know the total quantity. That's easy enough: var total = listSales.Sum(entry => entry.Quantity); Then you need to work out the cutoff point, which is 1% of it: var cutoff = total / 100; For... more 12/11/2014 8:49:36 AM
In this case, the compiler doesn't need to create a class at all - it can just create a static method: public static Func<SomeClass> GetFactoryMethod() { return __GeneratedMethod; } private static SomeClass... more 12/10/2014 5:33:46 PM
I guess there must be an elegant way to directly read one digit each time. A digit is a character - so you want to read a single character at a time. Oddly enough, Scanner doesn't appear to be conducive to that. You could read a... more 12/10/2014 5:08:44 PM