Browsing 7239 questions and answers with Jon Skeet
So you want the word within the array which occurs earliest in the target string? That sounds like you might want something like: return array.Select(word => new { word, index = target.IndexOf(word) }) .Where(pair =>... more 5/15/2015 3:35:50 PM
No need for two statements at all... nor using a string conversion. Just use the key of each group, and the DateTime.Date property: var query = list.GroupBy(x => new { x.Tag, x.Time.Date }) .Select(g => new NewPoint ... more 5/15/2015 1:45:38 PM
Don't use a third-party class in this case - Android already has a Base64 class. Just use Base64.encodeToString(byte[], int) and Base64.decode(String, int). Note that base64-encoding is for binary data, so if your actual source is text,... more 5/15/2015 10:40:08 AM
You're currently combining two separable concepts: How do I convert between an instance of Person and a stream of binary data (or byte[])? How do I encrypt/decrypt an arbitrary stream of binary data (or byte[])? Those two concepts... more 5/15/2015 10:15:31 AM
If the client sends me a byte of value 0, it is not received by the server. Yes it is, but you're ignoring it: while ((r = input.read()) > 0) { You probably meant: while ((r = input.read()) > -1) { The second issue is,... more 5/15/2015 10:00:25 AM
I would avoid bringing the Java week-of-year into the picture at all - unless you can persuade MongoDB to stop being so broken, somehow. (That's a really odd definition of week-of-year; I'd normally use the ISO-8601 definition.) If you... more 5/15/2015 7:32:00 AM
Now I'm intentionally unlocking in b() which releases the lock so that other waiting thread could get the lock No, it doesn't fully release it - it just decrements the lock count. Before you call unlock, you've called lock twice, so... more 5/15/2015 7:12:39 AM
the app freeze in this point Yes, because you're doing a lot of work in the UI thread. Don't do that - never do that. You should probably do all that work in a background thread (either with BackgroundWorker or maybe Task.Run) and... more 5/15/2015 7:09:57 AM
This is the first problem: public static void main(String args[]); You're not actually declaring a method body here. It should be: public static void main(String[] args) { // Method body goes here } You should only use a ; at the... more 5/15/2015 5:57:43 AM
I would suggest returning a ParseResult<T>, which is defined as something like: public struct ParseResult<T> { // Or an exception, or a way of creating an exception private readonly bool success; private readonly T... more 5/14/2015 2:34:04 PM