Browsing 7239 questions and answers with Jon Skeet
I thought that "x = x" in the constructor would be like "23 = 23". Within the constructor, the meaning of the simple name x is always just the parameter. So the assignment x = x in the constructor takes the value of the x parameter... more 5/2/2014 4:24:57 PM
You can't have an internal class in the inheritance tree of a public class, but you can force users to derive from CustomFileReader instead of Reader, by making the only constructor of Reader internal: public abstract class Reader { ... more 5/2/2014 4:21:55 PM
this method for example is a setter so it receives as a parameter (double or string or int etc...) and return void. That's the problem - a method accepting a double isn't applicable for Action<object>, because an... more 5/2/2014 12:43:33 PM
You haven't shown anything in the getNameViaParameter method that affects any shared state within the servlet, so it should be fine. You won't end up with multiple calls for the same request in different threads, so as long as your method... more 5/2/2014 12:30:42 PM
It sounds like you just want: var query = Assembly.Load(...) .GetTypes() .Where(t => typeof(DataSource).IsAssignableFrom(t)); (The IsAssignableFrom part is the interesting bit, but I gave the... more 5/2/2014 12:08:50 PM
The compile-time type of this within Foo.DoSomething is just Foo, so the compiler can only infer the type argument as Foo. The simplest way of getting it to do it based on the execution-time type is probably: DoSomething((dynamic)... more 5/2/2014 12:07:12 PM
No, that's basically not possible. If you want something like that, you'd need a wrapper class type, e.g. public class Wrapper<T> { public T Value { get; set; } } Then you could use: var wrapper = new Wrapper<double> {... more 5/2/2014 11:23:42 AM
Any one dictionary can only have a single equality comparer. You can't ask it to find a key with respect to a particular equality comparer, because otherwise its stored hash codes will be useless, and it would have to just do a linear... more 5/2/2014 10:57:58 AM
If you only want to know whether there are any, I'd use: if (propertyAppliances.Select(pa => pa.Appliance.TypeId) .Except(engineers.Select(eng => eng.ApplianceTypeId)) .Any()) This... more 5/2/2014 10:53:27 AM
It sounds like you just want to use: foreach (var contactMethod in methodsToDelete.ContactMethods) You can't iterate over a ContactSaveRequest, but you can iterate over the IEnumerable<ContactMethod> that is returned by the... more 5/2/2014 10:26:55 AM