Back to basics: Access modifiers

Is everything in your application declared as either public or private? Here's an overview of the access modifiers available, maybe you are not using the right ones all the time. This is also for my reference, so here goes:

MyObject.cs //C#
public class MyObject { //anything can access
    public int MyInt {get;private set;} //all objects can read but only MyObject can write
    private int myInt; //only MyObject can access
    protected bool myBool; //only MyObject and objects inheriting from MyObject can access
	internal string myString; //only the current assembly can access (unless using InternalsVisibleToAttribute)
    protected internal object myObject; //any object in this assembly and objects inheriting from MyObject in other assemblies can access
	private readonly string myReadOnlyString = "hi"; //can only be assigned to in the definition or in the constructor
    protected virtual string myOverridableString {get;set;} //can be overriden in the inheritance chain
    private class MySubObject {} //only MyObject can access
    public static string MyStaticString; //access to this property is done through the type not through instances, so it is the same for all instances (hence "static") and can be thread unsafe
}

internal class MyInternalObject {} //only the current assembly can access

public sealed class MySealedClass {} //sealed means you cannot inherit from this class

public abstract class MyBaseObject {} //cannot be instantiated but can be inherited from

public partial class MyPartial {} //allows definition of class to be spread across multiple partials (e.g. for adding to auto-generated classes)

public static class MyExtensions {
    public static void ExtendedMethod(this Object o) {} //defines an extension method of the Object type
}

Hope this helps you to use the correct modifiers.