Browsing 7239 questions and answers with Jon Skeet
Rather than read the data into a byte array and decoding it yourself, just read it as a stream and let XDocument.Load detect the encoding from the data: using (HttpClient http = new HttpClient()) { using (var response = await... more 1/31/2016 10:20:18 PM
You're declaring a new a0 variable in each iteration of the loop, and always initializing it with the value 1100000. If you want to use the value from the previous iteration within the loop, you need to declare it outside the loop: int a0... more 1/31/2016 9:19:31 AM
Assuming you really mean you want to generate an appropriate expression tree with a ConstantExpression in, I think you'll have trouble doing that with an actual lambda expression. However, you could construct the relevant expression tree... more 1/29/2016 5:15:43 PM
You can - but then it would be a somewhat misleading piece of code. If I look at a variable called head, I'd expect it to be the head of a list - whereas if I do: head = head.next(); ... then head refers to something which isn't the... more 1/29/2016 2:05:20 PM
LINQ makes this easy with SelectMany and Enumerable.Repeat: var result = input.SelectMany(x => Enumerable.Repeat(x, x)).ToList(); The SelectMany is a flattening operation: for each input in the original sequence, generate a new... more 1/29/2016 11:07:08 AM
I believe I understand what may be going wrong here... you're currently using read(sigBytes) which does not guarantee that it will read all the data you've requested. In general, InputStream.read(byte[]) and InputStream.read(byte[], int,... more 1/29/2016 6:50:52 AM
You've got an O(n2) algorithm for no obvious reason. It's easy to make this O(n1/2)... Loop from 1 to the square root of n/2 (for variable i) - because when i is greater than sqrt(n/2) then i*i + j*j will be greater than n for any j... more 1/28/2016 10:07:53 PM
What are the rules for the characters that can be used in Java variable names? The rules are in the JLS for identifiers, in section 3.8. You're interested in Character.isJavaIdentifierPart: A character may be part of a Java... more 1/28/2016 7:32:22 PM
They create different types of objects. new ArrayList<>() creates a java.util.ArrayList, which can be added to, etc. Arrays.asList() uses a type which happens to also be called ArrayList, but is a nested type... more 1/28/2016 2:50:29 PM
The files I read are csv files which were created on solaris. I run the jar on Windows 2012 server Well that's probably the problem then. You're using the platform-default encoding for both reading and writing the file. If the files... more 1/28/2016 11:23:05 AM