[Solved] Why does MSDN documentation show protected methods for Random?


You seem to have several questions about the System.Random documentation. It lists three protected methods, but two of them are inherited from System.Object. The third one is Sample, which is documented to return “a random floating-point number between 0.0 and 1.0.”

To answer your title question, no, the MSDN documentation is not incorrect. That method does exist, and it does what it says.

You also ask “can we override those methods…?” Yes, we can. System.Random is not a sealed class, so we can inherit it, and Sample is overridable, so we can override it. Even if it were not overridable, it would still need to be documented, because a class inheriting Random might need to access it.

So to your question “how is that information going to help us,” it helps in several ways. If you create a class that inherits System.Random, you may need documentation on its protected methods, so that you know how to use (or override) those methods. If you are a framework developer, and are troubleshooting a bug in System.Random, you may need documentation on its internal implementation.

Also, the MSDN documentation is in the same format as a lot of other documentation, which is auto-generated from XML comments in the code. If MSDN documentation is similarly auto-generated, then it would be a big job to go through the entire framework and selectively hide things on a case-by-case basis, even if it were desirable to do so.

solved Why does MSDN documentation show protected methods for Random?