Browsing 7239 questions and answers with Jon Skeet
No, there's no such thing as an "extension indexer" right now. Extension methods are as close as you can get. However, it's entirely possible (but not guaranteed) that they'll come in C# 8. So your options are: Wait for C# 8 Use your own... more 7/20/2017 8:28:52 PM
You can assign values to "sub-properties" as it were, just not with that syntax. Here's a complete example: using System; public class Container { public Item Item { get; set; } = new Item(); } public class Item { public string... more 7/20/2017 10:24:33 AM
As you say, the error message is unfortunate, in that the problem is ambiguity rather than Where not being found at all (assuming you have a using directive for System.Linq). The problem is that the compiler can't infer the type argument... more 7/20/2017 10:08:49 AM
The entry point needs to be called Main, not main. That's also in-keeping with .NET naming conventions, which I'd strongly urge you to follow: Your namespace should be capitalized, e.g. Abc rather than abc Your display method should be... more 7/20/2017 6:18:42 AM
I'd separate this into three phases: Count word occurrences (e.g. by using a HashMap<String, Integer>) Sort the results (e.g. by converting the map into a list of entries and ordering by value descending) Output the top 1000... more 7/19/2017 3:34:55 PM
You can use @ to use a keyword as an identifier, so this should work: string _operator = item.@operator; Alternatively, you may well find that indexer access would be fine: string _operator = item["operator"]; more 7/19/2017 3:06:19 PM
You don't need to check whether the attribute already exists before using SetAttributeValue. Just: // Unconditional elem.SetAttributeValue("TAG", value); (There's no point even creating the XAttribute yourself.) From the... more 7/19/2017 10:39:54 AM
The operation x & 128 will never result in 1 for any value of x, because it's a bitwise operation. It will always either be 128 or 0, depending on whether that bit is set in x or not. (Note that 128 decimal = 10000000 binary, so... more 7/19/2017 10:27:13 AM
No, it's doing the right thing IMO. A LocalDateTime isn't "local to the server", it's "not in any specific time zone". If you've got a text value which indicates a date/time and any sort of time zone indicator (e.g. an offset from UTC or... more 7/18/2017 11:05:12 AM
The "index" is meaningless in a HashSet - it's not guaranteed to be the same as the insertion order, and it can change over time as you add and remove entries (in non-guaranteed ways, e.g. if you add a new entry it could end up in the... more 7/18/2017 9:03:51 AM