Browsing 7239 questions and answers with Jon Skeet
terminalOne is an array, not an individual plane. You could use: for (Plane plane : terminalOne) { plane.displayPlane(); } ... but I would personally consider overriding toString() in Plane instead: @Override public String... more 11/2/2013 8:42:26 AM
my code snippet has something different in that it will never cause an "unassigned" error Well it clearly does cause that error, which is why you asked the question, no? Even though you know that any time the exception is thrown,... more 11/2/2013 8:30:49 AM
Because both x and y are compile-time constants, so is x + y. The compiler knows that the result will overflow, so it complains about it. You can fix this by using an unchecked expression: int result = unchecked(x + y); From section... more 11/1/2013 8:42:13 PM
It should be fine so long as the machine you're copying it to has the full version of .NET - not just a client profile. You shouldn't need to copy anything - it should just be fine to pull it from the GAC. Just make sure you've got the... more 11/1/2013 8:39:12 PM
Well that certainly feels more like a property to me than a method - and it's certainly in-keeping with things like Nullable<T>.HasValue. Other differences to consider: You can generally bind against properties but not methods;... more 11/1/2013 8:27:15 PM
You normally serialize instances. You can't have an instance of a static class, so it makes no sense to serialize it. If you need to serialize the static state of a static class, then you should probably make it non-static to start with.... more 11/1/2013 3:55:16 PM
To quote slightly differently to the other answers, this is from section 3.6 of the C# 5 specification, which I find rather clearer and more precise than the "reference guide": Although out and ref parameter modifiers are considered... more 11/1/2013 3:34:41 PM
It looks like you're trying to handle the user opening multiple files. In that case, use FileDialog.FileNames instead of FileName. Ditto SafeFileNames. (I would also strongly recommend renaming the variables so their names are meaningful... more 11/1/2013 2:43:21 PM
If it's private, there's no significant benefit in making it a property. I'd just keep it as a field. I use properties as a way of communicating an API with other classes. more 11/1/2013 11:13:15 AM