Browsing 7239 questions and answers with Jon Skeet
You're calling a.eat(), so as far as the compiler is concerned, any Exception can be thrown - it only cares about the compile-time type of a. (It doesn't reason that the value of a is a reference to a Dog, and Dog.eat only throws... more 6/4/2015 5:56:42 AM
scan is just a label. It allow this later on: break scan; ... to allow the break statement to break out of the outer loop instead of the inner loop. See section 14.7 of the JLS for more details of labeled statements. more 6/3/2015 9:29:01 PM
You can use BinaryWriter to write the data to a file very easily: foreach (var value in samples32array) { writer.Write(value); } Now BinaryWriter is guaranteed to use little-endian format, so in your Matlab call, you should specify... more 6/3/2015 7:32:03 PM
All you need to do is add the element to the existing document root using the Add method, it seems: var doc = new XDocument( new XElement("order", new XElement("class"), new XElement("account", new... more 6/3/2015 6:55:52 PM
Yes, you can do this easily with async/await. For example: // If you don't have async equivalents, you could use Task.Run // to start the synchronous operations in separate tasks. // An alternative would be to use... more 6/3/2015 1:25:21 PM
So my question is why this private method got executed from other class? Well, it's only sort-of private. It's using explicit interface implementation - it's accessible via the interface, but only via the interface. So even within... more 6/3/2015 12:03:53 PM
How do I iterate over the loc values? The simplest way is to use the overload of Descendants which accepts an XName: foreach (var loc in siteMap.Descendants("loc")) { string value = loc.Value; ... } Currently, you're asking... more 6/3/2015 10:58:05 AM
Given that you've said the volume of output is low, the simplest option would probably be to just write a thread-safe writer which uses synchronization to make sure that only one thread can actually write to the file at a time. If you... more 6/3/2015 6:21:06 AM
I suspect the interviewer was referring to reflection. For example: var assembly = ...; // e.g. typeof(SomeType).Assembly var types = assembly.GetTypes(); var methods = types.SelectMany(type => type.GetMethods()); // etc You'd need... more 6/3/2015 6:01:34 AM
No, the default value for an optional parameter has to be a constant. You could use -1 as the default value as suggested in comments, or make it a nullable int and default it to null: public static int[] UpArray(int[] num, int? index =... more 6/2/2015 7:09:34 PM