In a recent interview I had this question.
Whats the error here? I know enough c# but I cant see an error. Can you?
Class x {
protected string t1;
public int t2;
}
Class y : x {
}
In a recent interview I had this question.
Whats the error here? I know enough c# but I cant see an error. Can you?
Class x {
protected string t1;
public int t2;
}
Class y : x {
}
Well in terms of errors, we could start with Class
instead of class
. In terms of bad practice, virtually every line of it is a bad idea in my view:
Basically, the types string
and int
are okay here - but every other non-whitespace, non-symbolic token would need changing before I let this into a codebase...
Class
instead of class
. A non-private field isn't a "real" error in that it's not an error from the compiler's point of view. I think it's more likely I'd end up occasionally using non-private fields in very specialized cases than that I'd ever have a class called x
.
Feb 5, 2012 at 18:49