Browsing 7239 questions and answers with Jon Skeet
This simplest approach is to let LINQ to XML do this automatically by specifying the namespace in the element name: XNamespace ns = "http://ws.plimus.com"; var docXml = new XElement(ns + "param-encryption", new XElement(ns +... more 12/23/2014 12:23:30 PM
You're currently looking for a Code attribute, whereas in your XML it's an element. So FirstOrDefault() doesn't find anything and returns null, hence the exception on the next statement. Additionally, you can just use the LINQ to XML... more 12/23/2014 11:50:39 AM
Basically, Java has slightly different set of syntax rules, by the sounds of it. When the grammar says you've got a variable declaration with an initializer, such as this: Box box = new Box(); ... it knows that Box has to be the name of... more 12/23/2014 10:19:30 AM
I would try to get out of the dynamic part as quickly as possible. You can then convert to DateTime and use the Date part for the grouping. If you need to be dynamic in the field name, you can do that, but end up with an... more 12/23/2014 9:34:43 AM
You either want to use Any or All, depending on whether you want to find objects where all of the parameters match or any of them. So something like: var result = components .Where(o => parameters.Any(p =>... more 12/23/2014 8:34:09 AM
For instance methods, I don't think it would make sense for them to be cached. You'd have to cache one method per instance... which would either mean an extra field within the class associated with the method - one per public method,... more 12/23/2014 8:26:08 AM
Acquiring the lock implies that you're trying to access a guarded section of code so it should block (if you're not lucky i.e. you should block at least in certain scenarios) If that's the behaviour you want, you should just use the... more 12/22/2014 12:47:21 PM
Why the try catch is again included inside the try block. Not sure on this one. It may just be the way that ildasm chooses to decompile it. ECMA-335 says there are restrictions on how SEHClause elements can be specified after a... more 12/22/2014 11:34:35 AM
It sounds like you just need: string text = File.ReadAllText("file.txt"); There's no such thing as "hex values" in a file - they're just bytes which are shown as hex in various editors geared towards editing non-text files. The above... more 12/22/2014 9:39:58 AM
It's an implicitly typed array creation expression - it lets the compiler infer the array type, a bit like using var but for arrays. So in your case, it's equivalent to: _dict.Add("Header_" + headerId, new XmlNode[] { header }); It was... more 12/22/2014 8:44:48 AM