Browsing 7239 questions and answers with Jon Skeet
You don't want to "sum the IDs" - you just need the average of the prices, which you can get using the Average method. If you want the count, just call Count(): AverageRevenuePerItem = pr.Average(y => y.ItemPrice), TotalSalesPerItem =... more 11/26/2016 6:35:21 PM
This line: int d = c; says "Declare a variable called d, of type int, and make its initial value equal to the current value of d." It doesn't declare a permanent connection between d and c. It just uses the current value of c for the... more 11/26/2016 9:12:56 AM
I don't believe you can specify table names as parameters... only values can be specified as parameters. Instead, either have a white-list of permitted table names, or at least a white-list of permitted characters within table names,... more 11/25/2016 4:41:32 PM
You need to: Make sure the pattern is right Specify the right locale In this case, you want an English locale for English month names: SimpleDateFormat sdf = new SimpleDateFormat("MMM d, yyyy h:mm:ss a", Locale.ENGLISH); Note that... more 11/25/2016 12:37:11 PM
You're looking for an element called TxId in no namespace - but your element is implicitly in the "urn:com.company:request.001" namespace, which is inherited from its ancestor. So you need: element.Descendants(ns + "TxId").First() more 11/24/2016 3:45:52 PM
An InvalidOperationException will be thrown if s.CurrentJobId is actually null anyway. That's almost always the best outcome for situations of "the world is not the way I expect it to be" so it makes sense to use the code exactly as-is. more 11/24/2016 11:35:15 AM
You can just use default(T) instead: public static T Parse<T>(this string x, T defaultValue = default(T)) However, I would strongly question the design here - you're not really writing a generic method, but a method which accepts... more 11/23/2016 9:46:33 PM
You specify the language via the relevant ISO or BCP-47 tag in the Document part of the request. So for example: Document document = Document.newBuilder() .setLanguage("en") .set... // Call other setters .build(); more 11/23/2016 1:53:48 PM
(Disclaimer: I work in the Google Cloud Platform team, but this is a personal answer.) All of these are solutions which allow you to host your applications in the cloud. You can view them as a sort of spectrum of control/automatic... more 11/23/2016 11:05:33 AM
Just use typeof instead - it's much simpler, and doesn't require any framework support: public sealed class SomeClassController : ApiController { private static readonly ILog Log = ... more 11/23/2016 8:30:00 AM