Browsing 7239 questions and answers with Jon Skeet
Your enum is of individual days of the week - a variable of type DayOfWeek should only be expected to refer to a single day. If you're trying to store multiple values, you should look at an EnumSet: EnumSet<DayOfWeek> days =... more 3/5/2014 5:30:30 PM
It sounds like you just want to read the file as a byte array and reverse the bit order for each byte. byte[] data = File.ReadAllBytes("file.dat"); for (int i = 0; i < data.Length; i++) { data[i] = ReverseBits(data[i]); } // Now... more 3/5/2014 5:19:33 PM
Typically I put the test classes in the same package, but under a different source root. Aside from anything else, this allows you to test members (and indeed classes) which have default visibility. Sometimes I'll even make methods which... more 3/5/2014 4:50:51 PM
The first is type-safe because the list is empty, but still not advised. There's no benefit in using a raw type here. Better to design away from a warning than suppress it. The second is definitely not type-safe, as theList may be a... more 3/5/2014 4:21:27 PM
It's writing it to the output stream of the URLConnection - which is basically used for the body of an HTTP request (assuming it's an HTTP URL, of course). more 3/5/2014 3:17:15 PM
If you want to dispose of the IEnumerable<T>, you need to do that yourself with a using statement (or manual try/finally). A foreach loop does not dispose of the IEnumerable<T> automatically - only the iterator it returns. So,... more 3/5/2014 3:13:39 PM
You're calling GetEnumerator in the else block, but that's not going to automatically yield anything. It would be nice if you could have something like: // This doesn't actually work! yield all carArray; ... but there's no such... more 3/5/2014 2:46:05 PM
It's not clear why you're trying to use Select for this, but it's not working because List<T>.Add has a void return method, and the lambda expression you use in a projection has to return the value you're projecting to. I suggest you... more 3/5/2014 2:39:57 PM
I don't believe there's any way of doing this efficiently using HashSet<E>. (You could list all the keys and check them for equality, of course.) However, although the HashMap approach would be irritating, it wouldn't actually take... more 3/5/2014 1:43:41 PM
Is there a way to perform this convertion without creating new array and copying all the data? No. You can't change the size or bounds of an array once it has been created. more 3/5/2014 1:36:29 PM