Browsing 7239 questions and answers with Jon Skeet
Don't do the arithmetic in the query - do it before the query, so that you're basically specifying an "earliest publication creation time": // Deliberate use of UtcNow - you should almost certainly be storing UTC, not // local time... var... more 8/18/2014 2:27:15 PM
The simplest answer here is not to use StreamReader at all. Let the XML parser handle the encoding appropriately: public XmlDocument LoadDocument(String x) { XmlDocument document = new XmlDocument(); using (var stream =... more 8/18/2014 12:51:33 PM
Your current approach seems the simplest one to me, although it could be done in a single statement as: var element = new XElement("ValidationResults", doc.Element("ValidationResults") .Elements("ValidationResult") ... more 8/18/2014 10:47:32 AM
LINQ to XML would make this pretty simple: var doc = XDocument.Load(...); var bs = doc.Descendants("b").ToList(); foreach (var b in bs) { b.ReplaceNodes(); } (Use ReplaceAll instead of ReplaceNodes if you want to remove the... more 8/18/2014 10:07:42 AM
Yes, you can use: List<Object> list = new ArrayList<>(); list.add("A string"); list.add(new ArrayList<Foo>()); // etc It's usually not a good idea, as when you get items out of the list, it can be a pain to work out... more 8/17/2014 7:35:54 PM
I suspect this is the problem: Image img = Image.FromFile(file.FullName); That opens the file - but you never dispose the same object, so the file will be open until the object is finalized. Image implements IDisposable, so you should... more 8/16/2014 9:35:36 PM
This is binary serialization. It's not meant to be writing to a human-readable text file. For that, you should look into something like JSON or YAML. I'd strongly recommend against writing to a .txt file using ObjectOutputStream - it gives... more 8/16/2014 9:18:50 PM
So you want a list of the users such that all the countries in the list are present in the set of order destinations? Logically, that would be: query = from user in db where countries.All(c => user.Orders.Any(o =>... more 8/16/2014 9:09:27 PM
It's important to understand that float and double don't retain trailing zeroes. You have two options: Specify the format to include the number of decimal places you're interested in Use decimal, which does retain trailing zeroes It's... more 8/16/2014 8:52:59 PM
It seems to me that you don't need a separate block for this at all - you can just use SELECT COUNT(1) and ExecuteScalar: string sql = "SELECT COUNT(1) FROM MasterCompliant WHERE Discom = ?"; int count; // Open and close a connection... more 8/16/2014 8:21:48 AM