Making them private
explicitly makes the code more clear, since now you don't have to depend on developers knowing the default visibility in C#. This could thrown some developers off, so it's better to just be explicit and clear. For example, the default visibility in Java is package, not private, so this might throw off ex-Java programmers.
You can use it to imitate return type covariance (Note: After this answer was written, C# 9.0 added support for return type covariance). Eric Lippert's Explanation . Eric provides this example code:
abstract class Enclosure
{
protected abstract Animal GetContents();
public Animal Contents() { return this.GetContents(); }
}
class Aquarium : Enclosure
{
public new Fish Contents() { ... }
protected override Animal GetContents() { return this.Contents(); }
}
This is a work-around. public override Fish Contents() { ... }
is not legal, despite being safe.
In general, you should not use method hiding, as it is confusing to consumers of your class (the specific example above does not suffer from this problem). Just name your new method something else if you don't want to override an existing method.
A likely real-world situation where you would need method hiding is if the provider of a base class added a generic method which you had already added to a derived class. Such a program will compile (and give warnings) without the new keyword, but adding new
says, "I know my version of this method is replacing the base class's version. This is horrible and confusing, but we're stuck with it." That's still better than forcing the derived class to rename their method.
Just allowing the derived method to be treated as being an override would cause problems. Ignoring any concerns with implementing the compiler, the new method is semantically different from the base method, but polymorphism would cause the new method to be called when asked to call a method with the same name.
This situation is discussed in detail in this post by Eric Lippert.
Best Answer
Why would you need to inject private properties? That's not what DI is for. Injecting private properties would violate encapsulation.
One of the constructor overloads on your class should specify everything the class needs to instantiate. If the class can't specify what it needs in it's public API, then it doesn't need it.
From http://natpryce.com/articles/000783.html (emphasis mine):