Browsing 7239 questions and answers with Jon Skeet

How to solve this with a lambda

This is the question: " Write a program that extracts from a text all words which are palindromes, such as ABBA", "lamal", "exe". " And this is my code: public static...
Jon Skeet
people
quotationmark

x.Reverse() is calling Enumerable.Reverse(), which will return you an IEnumerable<char> - not a string. That's why Equals is never returning true. Here's an alternative: char[] chars = x.ToCharArray(); Array.Reverse(chars); return x... more 7/10/2014 8:35:51 PM

people

BufferedReader, read chars in an edittext gives strange chars

Ok, I am reading a .docx file via a BufferedReader and want to store the text in an edittext. The .docx is not in english language but in a different one (greek). I use: File...
Jon Skeet
people
quotationmark

Ok, I am reading a .docx file via a BufferedReader Well that's the first problem. BufferedReader is for plain text files. docx files are binary files in a specific format (assuming you mean the kind of file that Microsoft Word... more 7/10/2014 6:43:44 PM

people

How to get project id in Google Cloud Storage

I have activated Google Cloud Storage on my Gmail account, then created a new Project. As far as I see, and read from tutorials...
Jon Skeet
people
quotationmark

You should be able to see it in the Developer Console. Click on a project, and at the top it will tell you the project ID. (If you were looking for a way of getting this programmatically, please clarify this in your question - it's not... more 7/10/2014 4:54:32 PM

people

LINQ with inner enumerable query

I'm struggling to get my head around LINQ. In the example below I have three meetings. Jane Doe is assigned to two of those meetings. But the code below which I think should...
Jon Skeet
people
quotationmark

This is the problem: x.People.Select(y => y.Name == "Jane Doe").Any() You're using Select, which is a projection, when you meant to use Where, for filtering. Given that Select never filters out any items, you're basically returning... more 7/10/2014 4:32:59 PM

people

Generating XML with an arbitrary number of nodes

I'm new to working with java. I'm trying to write out an XML file which has this form: <option> <name>CompilerOptions</name> ...
Jon Skeet
people
quotationmark

You're calling option.appendChild() and passing it the result of doc.createElement(...).appendChild(...) But appendChild() returns the newly-appended child, not the node it was appended to. So you're actually calling... more 7/10/2014 4:25:10 PM

people

Error by converting date: Unparseable date in JAVA

I can't find the problem. I'm trying to convert the date: "Thu, 10 Jul 2014 13:33:26 +0200" from string to Date with this code: String formatType = "EEE, dd MMM yyyy HH:mm:ss...
Jon Skeet
people
quotationmark

You're creating a SimpleDateFormat without specifying a locale, so it'll use the default locale. By the looks of your variable names, that may not be English - so it'll have a hard time parsing "Thu" and "Jul". Try: String formatType =... more 7/10/2014 12:48:17 PM

people

Loop through XElement and remove some tags

please consider this code: public static XElement ToXElement<T>(this object obj,List<string> JustThisProperties) { using (var memoryStream = new MemoryStream()) ...
Jon Skeet
people
quotationmark

You can use the Remove extension method on IEnumerable<T> where T : XNode: xml.Elements() .Where(item => !JustThisProperties.Contains(item.Name.ToString())) .Remove(); (You might want to make JustThisProperties an... more 7/10/2014 11:37:15 AM

people

Can someone advise me what wrong with my Type or linq query

I am hoping someone can help, my error is cannot implicitly convert type system.collections.generic.List to xxxlistlitems I have this public IDListItems getIDList() { ...
Jon Skeet
people
quotationmark

Others have suggested changing the type of the variable - I'd recommend removing the variable entirely, along with the pointless catch block. You do need to change the return type as well though: public List<IDListItems>... more 7/10/2014 8:56:50 AM

people

illegal characters in path while Deserialise xml?

I have one xml and i need to deserialize as List. Actually i just used XSD2Code tool to generate the serialize and deserialize methods. All are working fine but when i pass the...
Jon Skeet
people
quotationmark

Right, now we've got your Deserialize method, the problem is obvious: stream = new StreamReader(xml); That's treating xml as a filename, not as XML. Either you should just have: public T Deserialize(string filename) { // There's no... more 7/10/2014 6:53:40 AM

people

Hash value does not match when decode a string

i have the following piece of code. It has been working in my Staging and pre-production environments as well as in production. How it has suddenly stopped working ONLY in the...
Jon Skeet
people
quotationmark

This is the problem - or at least a problem: Encoding.UTF8.GetString(mac3des.ComputeHash(Encoding.UTF8.GetBytes(dataValue))); ... and quite possibly the same for the previous lines. You're calling Encoding.UTF8.GetString with arbitrary... more 7/10/2014 6:49:10 AM

people