Browsing 7239 questions and answers with Jon Skeet
Various options: Use switch with a default: switch (level) { case GameLevel.None: // Whatever break; default: // Do something else // break } Use switch with explicit cases: // Note: if you add... more 5/6/2015 2:03:23 PM
The problem is that when you call Replace, newNode already has a parent - so it's cloned. If you remove it from its parent before calling ReplaceWith, then the element is added directly instead of a copy being... more 5/6/2015 1:51:48 PM
Two options you could consider: Use Stopwatch, which is designed for measuring elapsed times. Start that when you retrieve the server time, and then you can add the elapsed time to the server time whenever you need to. However, I don't... more 5/6/2015 6:18:43 AM
I have used this following code to achieve it and working fine, but is there any quick or easy way to achieve the same? Well there's a cleaner way to achieve it in my view - just don't use lambdas etc at all: foreach (var item in... more 5/6/2015 6:10:04 AM
It's not using reflection at all. The getResource(String) method called in your first snippet simply isn't declared on ConfigurationManagerUtils - it's declared on the Class class, as an instance method. If the second code snippet works as... more 5/6/2015 5:50:37 AM
The answer really depends on the language. In C# 2, we didn't have lambda expressions but we did have anonymous methods... so you can write: List<int> deductibles = GetDeductibles(); deductibles.RemoveAll(delegate(int i) {... more 5/5/2015 5:36:21 PM
Well, there's a reference conversion between string and object, in that every string reference can be treated as an object reference. This can be done transparently, with no modification to the value at all. That's why array variance can... more 5/5/2015 5:19:59 PM
Yes, you should be able to use something like: public async void SendSeveralRequestsAsync(MyClass myClass) { var client = SomeExternalServiceClient(); var tasks = myClass .Select(item => new ExternalServiceRequest { Value... more 5/5/2015 5:06:03 PM
I'd just change the method signature in the interface, and follow all the error messages you get. After all, in each method you're going to need to decide what to return, so you should really look at each of those classes individually.... more 5/5/2015 4:14:47 PM
Well you can just cast child to make the compiler resolve the field value with respect to ParentClass instead of ChildClass: ((ParentClass) child).value = "test"; But frankly I would a) avoid non-private fields; b) avoid knowingly... more 5/5/2015 3:29:34 PM