Browsing 7239 questions and answers with Jon Skeet
I very much doubt that a using statement will help here. Process.Dispose doesn't kill the other process - it just releases the CLR handle to the other process. (To be honest, I don't remember every seeing anyone use a using statement for... more 10/15/2013 3:39:40 PM
Absolutely - you basically want delegates. For example: public void DoSomething(string input, Action<int> callback) { // Do something with input int result = ...; callback(result); } Then call it with something like... more 10/15/2013 3:06:23 PM
When you say it's "not properly serialized" - that looks okay to me. That's one format for JSON dates, coming from the Javascript Date constructor taking a "milliseconds since the Unix epoch" as a parameter. So the value you've given is... more 10/15/2013 9:27:52 AM
This however leaves "empty spaces" in my list. No, it doesn't. It removes entries from the list completely. Other elements are moved appropriately. What it does do with the way you've written is skip the check for the next entry...... more 10/15/2013 8:54:34 AM
(Pretty much as noted in comments.) I suspect you're mostly seeing the effects of cache misses. When the collection is large, you'll get a lot of cache misses - particularly with the binary search, which potentially needs to touch a lot... more 10/15/2013 6:19:05 AM
If you're really just trying to store a file in a database, you don't need to worry about it being an image at all. The image file will already be in a "binary format" - you just need to store the file data. There may well be ways of doing... more 10/15/2013 6:11:22 AM
Exists should be fine - you just need to handle the possibility of p being null. bool nameExists = pList.Exists(p => p != null && p.Name == "testName"); Alternatively, make sure that your list doesn't contain any null... more 10/14/2013 9:30:41 PM
You're converting a number to an integer. So if you entered (say) 9.5 that would fail, because it's not an integer. You should almost certainly be using decimal.TryParse, noting that the return value will say whether parsing succeeded or... more 10/14/2013 6:59:20 PM
The ArrayList is a red-herring here - you're never even fetching the pieces out again. You'll see exactly the same behaviour with just this code: piece newPiece = new piece(1, 1, "red", "top"); piece newPiece2 = new piece(1, 2, "black",... more 10/14/2013 4:06:17 PM
t.start() creates a new thread, and calls run() from that. At that point, there are two threads running independently: the one that called start(), and the new one. The original thread returns from the constructor and then starts executing... more 10/14/2013 3:40:17 PM