Browsing 7239 questions and answers with Jon Skeet
It sounds like you just need to make it generic, and constrain the type to have a comparison: public static void InsertionSort<T>( RecordCollection records, Func<SesmicRecord, T> propertySelector) where T :... more 4/11/2017 3:04:09 PM
It's a matter of precedence. + binds more tightly than ??, so your code is effectively: var str2 = first ?? ("" + last) It sounds like you probably meant: var str2 = (first ?? "") + last But there's no point, given that string... more 4/11/2017 2:59:17 PM
Okay, I've got a solution. But it's really horrible. It involves creating a delegate from your method with a specific type, then using that to find the generic method, then constructing another specific method and invoking it. So we go... more 4/11/2017 2:40:54 PM
Everything is fine - that's how protected access is meant to work. It's specified in JLS 6.6.2.1: Let C be the class in which a protected member is declared. Access is permitted only within the body of a subclass S of C. In... more 4/11/2017 2:05:24 PM
It's a matter of phrasing what you want in a way that leads to a natural translation into LINQ: You want items from userEducation (that suggests you'll start with userEducation) Where none of ignoreEducationKeywords are... more 4/11/2017 12:02:45 PM
You need to start with Item as that's the root of each entry that you want in the end. You also need to provide the namespace of the elements, which is defaulted in the root element of the doc. So something like: XNamespace ns =... more 4/11/2017 10:17:26 AM
Your comparer just needs to compare by masking and then comparing the results. (Shifting works too - they're basically equivalent here, although masking allows your key to be any set of bits in the input, rather than necessarily the most... more 4/10/2017 4:06:40 PM
My problem is in the else body Well you're handling that in a different way to in the first if body. In the first if body, you're explicitly flushing the writer and rewinding the stream: sw.Flush(); stream.Position = 0; You're not... more 4/10/2017 2:46:17 PM
It's fine for a constructor to initialize properties, but it's rarely useful to have private automatically-implemented properties. I'd always use properties rather than fields for non-private state (whether those properties are... more 4/9/2017 4:49:34 PM
Your code is working already - it's calling the SpecialCustomer.Cname setter, as you can easily tell either by setting a breakpoint in it or adding some logging. (I just added a Console.WriteLine statement in the setter.) However, it's... more 4/9/2017 6:44:30 AM