Browsing 7239 questions and answers with Jon Skeet
A null conditional expression always has a nullable return type - after all, it has to have an overall result of null if the left hand side is null. So the type of myObject?.MyProperty.DoesNotExist() is Nullable<bool>, which can't... more 12/5/2016 9:50:09 AM
Well I'd avoid using repeated string concatenation, to start with. That's a very well known performance problem. In this case, you know the exact length you need to start with, so you don't even need a StringBuilder - a char[] is... more 12/5/2016 7:22:17 AM
You can use MoreLinq and its MinBy method: var pair = dictionary.MinBy(x => x.Value); var key = pair.Key; (And yes, this is O(N) rather than O(N log N) - more efficient than ordering. It won't need as much memory, either.) more 12/2/2016 7:11:16 PM
The problem is that you're using Function, which is for things which return a value. You should be able to use: ForEach(Sub(a) a.Remove()) more 12/2/2016 4:34:27 PM
This feels like a bit of an odd requirement to start with, to be honest - if something should work for any sequence of characters, then it should work for a string, which is a sequence of characters. If you really want to make it fail to... more 12/2/2016 9:52:12 AM
You can just use LINQ to JSON very easily in this case - parse the text as a JArray, then ask for the sha property of each object: using System; using System.Collections.Generic; using System.IO; using System.Linq; using... more 11/30/2016 7:23:47 AM
You've put the entire body of your try statement into the part that's meant to only be for initializing closeable resources. You want: // This part is initializing resources try (Connection connection = getConnection(); ... more 11/29/2016 11:26:00 AM
You need to specify the names you want in the anonymous object creation expression, e.g. .Select(x => new { SchoolName = x.tbl_SchoolProfile.Name, ClassName = x.tbl_Classes.Name, FeeHeadName = x.tbl_FeeHead.Name, ... more 11/29/2016 11:13:22 AM
I'd take the simple approach of "try the obvious date/time combination, and see whether it works": Try a DateTime using the "UTC date" and local time, in the given time zone. In this case, you'd end up with 2020-05-15T08:00:00 in... more 11/28/2016 4:40:06 PM
If you could do that, you'd lose half the point of using enums at all - the point is to keep them as separate types to avoid you making mistakes involving using types incorrectly. It seems to me like your dictionary should actually have... more 11/28/2016 8:11:15 AM