Browsing 7239 questions and answers with Jon Skeet
No - at least not in my understanding. If T is a non-nullable value type, the parameter == null check is effectively replaced with false by the JIT compiler; no execution-time check is performed. This is an optimization that only the... more 2/8/2018 12:47:33 PM
Why can't C# infer the type of row as it would if I was trying to iterate over a string[] for example? TL;DR: DataTable predates generics :( DataTable.Rows is declared to return DataRowCollection, which derives from... more 2/8/2018 10:08:12 AM
So this part is the problem: GrandParentData=new List<GrandParentData().Add( new GrandParentData { GrandFatherName = "",GrandMotherName =""}); There are three problems here: You're not closing the type argument You've got a... more 2/8/2018 8:08:52 AM
Firstly, I don't think you actually need that many patterns - I suspect you don't need both M and MM versions, for example. But the problem is that you're using HH with tt. HH means "24-hour clock", so a value of 12 means 12pm... but then... more 2/8/2018 7:44:29 AM
The problem is that the Contains LINQ method doesn't have the signature you expect - you're trying to check whether an IEnumerable<FrontPageProduct> contains an int... it can't, because it only has FrontPageProduct references. I... more 2/7/2018 9:51:20 AM
The JLS is pretty clear about this, in section 8.6: It is a compile-time error if an instance initializer cannot complete normally (ยง14.21). In your first example, the instance initializer can't complete normally. In the second... more 2/6/2018 2:41:32 PM
The result of a hash isn't UTF-8-encoded text, and shouldn't be treated that way. Convert it to hex or base64. For example: string computedHashString = Convert.ToBase64String(computedHash); Fundamentally, you need to treat data... more 2/6/2018 2:24:52 PM
Basically, that's not how you handle namespaces in LINQ to XML. You never specify a string with a colon in - instead, you build up an XName from an XNamespace and a string. The good news is that LINQ to XML handling of namespaces is... more 2/2/2018 2:37:15 PM
You can't do it in the argument list, no. You could use pattern matching for this, but I wouldn't advise it: if (FuncGetStr() is string result && !string.IsNullOrEmpty(result)) That keeps the declaration within the source code... more 2/2/2018 11:57:29 AM
Why local functions hide methods? Basically it's introducing the method name into the declaration space inside the method. Within that declaration space, the name only refers to the local method... just as it does for a local... more 2/2/2018 9:30:34 AM