Browsing 7239 questions and answers with Jon Skeet
I would separate "I only need one value for my whole web service" from "this class should be a singleton". The latter is one possible implementation, but it's certainly not the only one. I assume this is part of some configuration data... more 2/25/2015 10:38:26 AM
Your query expression is entirely broken at the moment - you're trying to use a mixture of query expressions and non-query-expressions. Additionally, constructing a SelectListItem and then using Distinct on that seems like a bad idea to... more 2/25/2015 10:29:01 AM
My guess is that your real code has a value of something like 20150225071945 - so not actually the literal YYYYMMDDHHMMSS. If that's the case, I would parse the value as a DateTime rather than extracting substrings: DateTime dateTime =... more 2/25/2015 7:22:31 AM
Your first problem is that the XML you originally gave isn't valid. You're masking that by returning "" whenever you encounter an exception, so you don't have any information any more. So the first thing to do IMO is remove the spurious... more 2/25/2015 7:13:36 AM
It's not entirely clear what output you're expecting, but given your example code, I suspect you just want: byte[] bytes = new byte[list.size()]; for (int i = 0; i < list.size(); i++) { bytes[i] = (byte) list.get(i).intValue(); } more 2/25/2015 6:55:07 AM
Assuming in your second snippet you'd actually call Monitor.Exit, the difference is explained in the documentation: This overload always sets the value of the variable that is passed to the ref parameter lockTaken, even if the method... more 2/24/2015 6:41:12 PM
The problem is your extra from clause: from productSeries in productSeriesGroup.DefaultIfEmpty() You should ditch that, and just use: let productSeries = productSeriesGroup.FirstOrDefault() ... or just use... more 2/24/2015 5:15:34 PM
You need to broaden your expectations a bit - in order for Math.Cos(x) to be genuinely equal to 0, you'd either need inaccuracy in Cos (which will happen, of course) or for x to have an irrational value. Instead, you should work out some... more 2/24/2015 3:49:51 PM
Assuming you can load the assembly itself, you can use Assembly.GetCustomAttributes: var asm = ...; var internals = asm.GetCustomAttributes(typeof(InternalsVisibleToAttribute), false); var... more 2/24/2015 3:45:37 PM
Just make the parameter a uint or a ushort. That will prevent negative input at compile-time. It won't prevent 0, however... I assume you're really after non-negative input rather than strictly positive input. If your method has to accept... more 2/24/2015 3:18:04 PM