Browsing 7239 questions and answers with Jon Skeet
Well not quite like that, but you could use a namespace alias directive: using System.Web.UI.WebControls; using text = iTextSharp; ... text::ListItem l = new text::ListItem(); You'd then not want a straight using directive for... more 12/12/2014 12:33:12 PM
As of C# 6, you can use the nameof operator: ctrl.DataBindings.Add(nameof(foo.Val), /* other arguments as before */); Before C# 6, there's no really simple way to do this at compile-time. One option, however, is to have unit tests which... more 12/12/2014 10:41:35 AM
You don't want to check the message - you want to check the SQL specific number. You can use the SqlException.Number property for this. I would use: // I think this is right, based on //... more 12/12/2014 10:29:09 AM
Because that's the way the language is designed. Any class implementing the interface will definitely have Object as an ultimate ancestor, so at execution time, those methods will definitely be available. This is specified in JLS 9.2: ... more 12/12/2014 9:21:23 AM
In the scenario you've shown, there isn't much obvious benefit. However, as a pattern it can be useful in my experience - particularly if the method performs validation. Guava's Preconditions.checkNotNull method is a great example of... more 12/12/2014 9:20:00 AM
Well, you could a conditional operator to make it clearer - at least to my eyes: return boolA && boolB ? "A" : boolA ? "B" : boolB ? "C" : "D"; Once you get used to this way of writing multiple conditional operators,... more 12/12/2014 8:59:35 AM
It's not clear why you're trying to use an anonymous method here. The problem is that you're creating a delegate type with two parameters, but you're not passing arguments (values for those parameters) into Invoke. I suspect you just... more 12/12/2014 8:20:36 AM
This has nothing to do with using a dictionary - it's simply because you're using characters with special meaning in regular expressions (+, ( and )) without quoting them. You'd get the same issue if you simply had value =... more 12/12/2014 7:06:13 AM
Both your getter and your setter are calling themselves. Remember that properties are just groups of methods, effectively. Your class really looks like this, but with a bit of extra metadata: public class ConnectionElement :... more 12/12/2014 6:56:09 AM
It sounds like you're interested in the intersection, basically. LINQ to the rescue! var firstCommon = a1.Intersect(a2).FirstOrDefault(); The documentation for Intersect would suggest this will return the items in the order of a2: ... more 12/11/2014 7:49:21 PM