Browsing 7239 questions and answers with Jon Skeet
A hash code is 32 bits in size. A char in Java is 16 bits in size. So in theory, all 2-character strings could have different hash codes, although some of those hash codes would have to collide with the hash code of the empty string and... more 9/12/2014 1:07:46 AM
Just leaving the value empty on the RHS should be fine: password= Sample code: import java.io.*; import java.util.*; class Test{ public static void main(String [] args) throws Exception { Properties props = new... more 9/12/2014 12:43:36 AM
I would just write it without any LINQ, to be honest- after all, you're modifying a collection rather than just querying it: void TrimList(List<string> list) { int lastNonEmpty = list.FindLastIndex(x =>... more 9/12/2014 12:32:52 AM
You're currently printing out the result of calling toString() on the byte[]. That's never a good idea - arrays don't override toString(). You should use the new String(byte[], Charset) constructor: String text = new String(bytes,... more 9/12/2014 12:22:45 AM
It's necessary to specify that you want to assign the value to the field, rather than the parameter or local variable: public void setFoo(Foo foo) { this.foo = foo; ^ ^ | \--- Take the value of the... more 9/11/2014 11:58:24 PM
It's very easy to write code to convert encodings - although I'd expect there are tools to do it anyway. Simply: Create one FileInputStream to the existing file, and wrap it in an InputStreamReader with the appropriate encoding Create... more 9/11/2014 9:14:51 PM
You need to create the appropriate delegate type, then pass that to the Expression.Lambda method. For example: using System; using System.Collections.Generic; using System.Linq; using System.Linq.Expressions; class Test { static void... more 9/11/2014 5:56:45 PM
You can just use charAt(0) to get the first character of a string... just like you're already doing for your key. Note that if you use a parameterized Map.Entry instead of the raw type, you won't need the toString call either: for... more 9/11/2014 4:51:32 PM
As of C# 6, you can write fairly compact struct initializers: public struct Key { public string Name { get; } public int Rating { get; } public Key(string name, int rating) { this.Name = name; this.Rating... more 9/11/2014 12:20:28 PM
Why does this happen? Because the Where call is receiving a type argument of ParentQueryElement as TSource. It creates a result based on TSource as a new object... so you end up with something which "knows" about ParentQueryElement... more 9/11/2014 3:52:12 AM