Browsing 7239 questions and answers with Jon Skeet
Two options. You could select the parent node to remove: xml.Descendants() .Where(x => x.Name.LocalName == "dependentAssembly" && (string)x.Attribute("dependencyType") == "install") .Select(x =>... more 8/6/2014 6:44:09 AM
You're trying to initialize a rectangular array - whereas what you're providing would be more suitable as a jagged array. A rectangular array is a single array with multiple dimensions - whereas a jagged array is an array of arrays - i.e.... more 8/5/2014 8:36:18 PM
You should initialize the Random() instance outside your loop - or ideally, just once. (The documentation states that it's thread-safe, so you shouldn't need one per thread or anything like that.) Basically, it's seeding a new instance of... more 8/5/2014 8:13:57 PM
Well this is probably the first problem: InputStreamReader reader1 = new InputStreamReader(in); That's loading the file using the platform default encoding, which may or may not be appropriate for the file in question. Likewise... more 8/5/2014 2:39:33 PM
You can use let in a foreach loop: // Query modified slightly to make more sense... foreach (var X in from X in Y let varA = X.A let varB = X.B where method(varA, varB) ... more 8/5/2014 2:25:46 PM
There are two problems here: You're using the implicit conversion from int when you're initializing the fields... that expects the value to already be there. You should be using the constructor instead. So this: public static readonly... more 8/5/2014 11:46:11 AM
In the loop I assign a new Object to the reference Well, you assign a new reference as the value for s. s is just a local variable though, which was initialized with the value of the element. It's not tied to the element in the list... more 8/5/2014 11:16:11 AM
That sounds like a join on the two original ones, followed by a conversion: var merged = dicA.Join(dicB, pair => pair.Key, pair => pair.Key, (a, b) => new { Key = a.Value, Value = b.Value }) ... more 8/5/2014 11:07:41 AM
You're calling string.Format with a string. That's not going to apply numeric formatting. Try removing the second line: double? valueFromDB = 1E-08; string formattedString = String.Format("{0:N30}", valueFromDB.Value); Or alternatively,... more 8/5/2014 9:48:30 AM
No, you can't access parameter values via reflection. You can get the names, types, attributes etc - but not the values. That's true of methods, constructors, property setters, indexers etc. You could potentially do it in a debugger API,... more 8/5/2014 9:23:47 AM