Browsing 7239 questions and answers with Jon Skeet
You don't need to read the whole thing to memory before writing it to disc. Just copy straight from the network stream to a FileStream: byte[] length = new byte[4]; // TODO: Validate that bytesRead is 4 after this... it's unlikely but... more 12/26/2014 11:26:50 AM
It's because Path is a type parameter here - you've declared a generic type, with Path as the type parameter. I suspect you *wanted: public class TypeOption implements Option<Path> { At that point, Path refers to the existing type... more 12/25/2014 12:41:29 PM
You should probably make user an instance variable instead of a local variable - in other words, declare it in your class: private string user; then in Username() (which should be renamed to DetectUserName or something similar) you... more 12/25/2014 9:15:35 AM
I believe your assumption for the reasoning behind it - that two RuntimeMethodInfo instances can be compared by reference equality - is correct. Your assumption that it's broken isn't correct though. The two MethodInfo objects here are... more 12/25/2014 8:24:37 AM
Now we can see the string values for the latitude and longitude, I suspect I know the problem. Double.parseDouble will throw an exception for a string like this: 41,352979. My guess is that somewhere you're catching Exception and... more 12/24/2014 3:18:18 PM
This is the problem: listePaysT.Wait(); That will block until the task has completed... so you're blocking your UI thread. Worse, the async methods will need to return to the UI thread in order to continue, so you've got a... more 12/24/2014 2:52:33 PM
so it should be able to return true without evaluating any elements No, in order to check that none of the elements match, it has to check everything. In other words, if it returns true then it will definitely have looked at... more 12/24/2014 12:11:51 PM
The decoded data isn't plain text data - it's just binary data. So write it with a FileStream, not a FileWriter: // If your Base64 class doesn't have a decode method taking a string, // find a better one! byte[] decodedBytes =... more 12/24/2014 11:57:01 AM
One option is to add another parameter: a Func<Dna, T>: private static T GetFruit<T>(Dna dna, Func<Dna, T> ctor) where T : Fruit { // I assume your real code does more here? return ctor(dna); } Then you can... more 12/24/2014 10:44:42 AM
Well, you could make it very explicit: if (customerIDExists) { ... } if (companyInvalid) { ... } if (!customerIDExists && !companyInvalid) { // Add user to DB } Or just use the fact that you haven't got an error... more 12/24/2014 10:18:39 AM