public vs. internal methods on an internal class

ScottS picture ScottS · Apr 2, 2009 · Viewed 25.7k times · Source
internal class Foo
{
  public void Fee()
  {
    Debug.WriteLine("Fee");
  }

  internal void Fi()
  {
    Debug.WriteLine("Fi");
  }
}

I'm thinking that Fee() and Fi() are equally accessible since the entire class is already internal. Am I overlooking something? Is there any reason to choose public or internal for the methods in a case like this?

Answer

Reed Copsey picture Reed Copsey · Apr 2, 2009

The internal class Foo declaration will override the accessibility of the public void Fee() method, effectively making it internal.

In this case, using internal vs. public on the methods will have the same effect. The only reason I would choose public methods vs. internal methods in a case like this would be to ease transitioning to a public class in a future version, should you choose to do so.