Browsing 7239 questions and answers with Jon Skeet
You can add your own extension methods easily enough. It's not immediately clear whether you're using IQueryable<> or IEnumerable<> (your code wouldn't compile either way, due to casing issues and the fact that no Where method... more 11/16/2013 8:34:52 AM
Because the data is read in by a BufferedReader, I have to convert from char[] to byte[] initially: That's a huge problem. You've compressed the data. It's arbitrary binary data. You should absolutely not be treating it as text. It's... more 11/15/2013 10:32:05 PM
Why does the code have two return states, It has two yield statements, Will both work? Yes. yield return will yield the given value to the method which is asking for the "next" value... but when the next value is asked for again, the... more 11/15/2013 10:20:47 PM
I suggest you introduce an attribute which you decorate each type with, and extract that when you need to. You won't be able to validate at compile-time that the type has the right type, but there's not a lot you can do about that. Unit... more 11/15/2013 10:07:54 PM
You're incrementing i in the each of the blocks as well as in the main loop "header". Indeed, because you've got one i++; in an else statement for the last if statement, you're sometimes incrementing i twice during the loop. Just get rid... more 11/15/2013 7:34:59 PM
EDIT: If you know that size(), get(index) and set(index, value) are all constant time operations for the operations you're using (e.g. for ArrayList), I would personally just skip the iterators in this case: for (int i = 0; i <... more 11/15/2013 11:53:33 AM
Just set all the parameters to suitable default values. Then overwrite them with the "real" values as you find them in your input. Note that if some of your columns are primary keys, you can't usefully use default values for those -... more 11/14/2013 9:51:41 PM
If you're just trying to create a document with those elements, you can use: XDocument filteredDocument = new XDocument(new XElement("root", bar)); (That will create a document with a root element of <root>, and all the elements... more 11/14/2013 6:35:58 PM
It sounds like you want: var moddedFiles = (string[]) files.Clone(); That will create a shallow copy of the array, which is largely equivalent to a deep copy when it comes to strings, as they're immutable. However, a cleaner (IMO)... more 11/14/2013 4:28:59 PM
As you can see this is not that we should receive. Why not? I strongly suspect that's the closest Single value to the Double you've given. From the documentation for Single, having fixed the typo: All floating-point numbers have... more 11/14/2013 3:10:21 PM